darknet
darknet copied to clipboard
error with opencv=1 please help me
collect2: error: ld returned 1 exit status
Makefile:77: recipe for target 'darknet' failed
make: *** [darknet] Error 1
who can help me ? thanks
I am having the same issue trying to compile with opencv
libdarknet.a(image_opencv.o): In function
image_to_ipl':
image_opencv.cpp:(.text+0x2f): undefined reference to cvCreateImage' libdarknet.a(image_opencv.o): In function
image_to_mat':
image_opencv.cpp:(.text+0x2fc): undefined reference to cv::cvarrToMat(void const*, bool, bool, int, cv::AutoBuffer<double, 136ul>*)' image_opencv.cpp:(.text+0x305): undefined reference to
cvReleaseImage'
libdarknet.a(image_opencv.o): In function mat_to_image': image_opencv.cpp:(.text+0x3a6): undefined reference to
_IplImage::_IplImage(cv::Mat const&)'
libdarknet.a(image_opencv.o): In function open_video_stream': image_opencv.cpp:(.text+0x441): undefined reference to
cv::VideoCapture::VideoCapture(cv::String const&)'
image_opencv.cpp:(.text+0x449): undefined reference to cv::String::deallocate()' image_opencv.cpp:(.text+0x4e9): undefined reference to
cv::VideoCapture::VideoCapture(int)'
image_opencv.cpp:(.text+0x508): undefined reference to cv::String::deallocate()' libdarknet.a(image_opencv.o): In function
get_image_from_stream':
image_opencv.cpp:(.text+0x71a): undefined reference to cv::fastFree(void*)' image_opencv.cpp:(.text+0x783): undefined reference to
cv::fastFree(void*)'
image_opencv.cpp:(.text+0x7db): undefined reference to cv::Mat::deallocate()' image_opencv.cpp:(.text+0x9df): undefined reference to
cv::Mat::copySize(cv::Mat const&)'
image_opencv.cpp:(.text+0xa0f): undefined reference to cv::Mat::deallocate()' libdarknet.a(image_opencv.o): In function
load_image_cv':
image_opencv.cpp:(.text+0xaf1): undefined reference to cv::imread(cv::String const&, int)' image_opencv.cpp:(.text+0xb82): undefined reference to
cv::fastFree(void*)'
image_opencv.cpp:(.text+0xc0e): undefined reference to cv::fastFree(void*)' image_opencv.cpp:(.text+0xc16): undefined reference to
cv::String::deallocate()'
image_opencv.cpp:(.text+0xd69): undefined reference to cv::fastFree(void*)' image_opencv.cpp:(.text+0xde3): undefined reference to
cv::fastFree(void*)'
image_opencv.cpp:(.text+0xe42): undefined reference to cv::Mat::copySize(cv::Mat const&)' image_opencv.cpp:(.text+0xef4): undefined reference to
cv::Mat::deallocate()'
image_opencv.cpp:(.text+0xf04): undefined reference to cv::Mat::deallocate()' image_opencv.cpp:(.text+0xf14): undefined reference to
cv::Mat::deallocate()'
image_opencv.cpp:(.text+0xf29): undefined reference to cv::String::deallocate()' libdarknet.a(image_opencv.o): In function
show_image_cv':
image_opencv.cpp:(.text+0xfdf): undefined reference to cv::imshow(cv::String const&, cv::_InputArray const&)' image_opencv.cpp:(.text+0xfe7): undefined reference to
cv::String::deallocate()'
image_opencv.cpp:(.text+0xfef): undefined reference to cv::waitKey(int)' image_opencv.cpp:(.text+0x1072): undefined reference to
cv::fastFree(void*)'
image_opencv.cpp:(.text+0x10a8): undefined reference to cv::Mat::deallocate()' image_opencv.cpp:(.text+0x10c1): undefined reference to
cv::String::deallocate()'
libdarknet.a(image_opencv.o): In function make_window': image_opencv.cpp:(.text+0x111c): undefined reference to
cv::namedWindow(cv::String const&, int)'
image_opencv.cpp:(.text+0x1124): undefined reference to cv::String::deallocate()' image_opencv.cpp:(.text+0x1146): undefined reference to
cv::setWindowProperty(cv::String const&, int, double)'
image_opencv.cpp:(.text+0x114e): undefined reference to cv::String::deallocate()' image_opencv.cpp:(.text+0x117f): undefined reference to
cv::resizeWindow(cv::String const&, int, int)'
image_opencv.cpp:(.text+0x1187): undefined reference to cv::String::deallocate()' image_opencv.cpp:(.text+0x11b8): undefined reference to
cv::moveWindow(cv::String const&, int, int)'
image_opencv.cpp:(.text+0x11c0): undefined reference to cv::String::deallocate()' image_opencv.cpp:(.text+0x11d2): undefined reference to
cv::String::deallocate()'
image_opencv.cpp:(.text+0x11e5): undefined reference to cv::String::deallocate()' image_opencv.cpp:(.text+0x11f8): undefined reference to
cv::String::deallocate()'
image_opencv.cpp:(.text+0x120b): undefined reference to cv::String::deallocate()' libdarknet.a(image_opencv.o):image_opencv.cpp:(.text._ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE13static_deleteEPPv[_ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE13static_deleteEPPv]+0x15): more undefined references to
cv::String::deallocate()' follow
libdarknet.a(image_opencv.o): In function cv::String::String(char const*)': image_opencv.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x30): undefined reference to
cv::String::allocate(unsigned long)'
libdarknet.a(image_opencv.o): In function cv::Mat::~Mat()': image_opencv.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x89): undefined reference to
cv::Mat::deallocate()'
image_opencv.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x72): undefined reference to cv::fastFree(void*)' collect2: error: ld returned 1 exit status Makefile:77: recipe for target 'darknet' failed make: *** [darknet] Error 1
@tmarkwell16 I have the same issue, did you find a way to fix this ?
@qlerebours I believe I did, however I just reinstalled my os. I will try to fix this again!!
I fixed this by installing OpenCV following this tutorial on Ubuntu: https://www.learnopencv.com/install-opencv3-on-ubuntu/ I had the error when using another tutorial to install opencv2
libdarknet.a(image_opencv.o): In Funktion »open_video_stream«:
image_opencv.cpp:(.text+0x4b9): Warnung: undefinierter Verweis auf »cv::VideoCapture::VideoCapture(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)«
image_opencv.cpp:(.text+0x5c3): Warnung: undefinierter Verweis auf »cv::VideoCapture::VideoCapture(int, int)«
libdarknet.a(image_opencv.o): In Funktion »load_image_cv«:
image_opencv.cpp:(.text+0xc0e): Warnung: undefinierter Verweis auf »cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)«
libdarknet.a(image_opencv.o): In Funktion »show_image_cv«:
image_opencv.cpp:(.text+0x11f1): Warnung: undefinierter Verweis auf »cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)«
libdarknet.a(image_opencv.o): In Funktion »make_window«:
image_opencv.cpp:(.text+0x13fa): Warnung: undefinierter Verweis auf »cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)«
image_opencv.cpp:(.text+0x1463): Warnung: undefinierter Verweis auf »cv::setWindowProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, double)«
image_opencv.cpp:(.text+0x14dd): Warnung: undefinierter Verweis auf »cv::resizeWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int)«
image_opencv.cpp:(.text+0x1559): Warnung: undefinierter Verweis auf »cv::moveWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int)«
collect2: error: ld returned 1 exit status
Makefile:77: recipe for target 'darknet' failed
make: *** [darknet] Error 1
Facing similar problems
I have the same error.Has anybody fixed it? Thanks a lot!
In Makefile
:
Change to OPENCV=0
make
Change back to OPENCV=1
make
again.
I'm using Arch Linux, OpenCV 2 (Installed from AUR)
Any solution? I check with Opencv 3.4.6
and Opencv 4.1.1
on the raspberry pi with the version:
Distributor ID: Raspbian Description: Raspbian GNU/Linux 10 (buster) Release: 10 Codename: buster
but both gave me the same error. I read all the threads, but I don't see any solution that works for me.
/usr/bin/ld: libdarknet.a(image_opencv.o):image_opencv.cpp:(.text._ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE13static_deleteEPPv[_ZN7cvflann7anyimpl14big_any_policyIN2cv6StringEE13static_deleteEPPv]+0x18): more undefined references to cv::String::deallocate() follow collect2: error: ld returned 1 exit status make: *** [Makefile:77: darknet] Error 1
@JunseongAHN I also encountered this error information with Centos7 and opencv-2.4.5(yum installed) I just solved this disturbing question with installing source opencv-4.1.0 (use the default installation path), and you maybe pay attention to the following points : darknet-master seem uses pkg-config to locate the lib of opencv4 (darknet-master/Makefile)
ifeq ($(OPENCV), 1)
COMMON+= -DOPENCV
CFLAGS+= -DOPENCV
LDFLAGS+= `pkg-config --libs opencv4 2> /dev/null || pkg-config --libs opencv`
COMMON+= `pkg-config --cflags opencv4 2> /dev/null || pkg-config --cflags opencv`
however in opencv-4.1.0/CMakeLists.txt, it is deprecated - -,you need set the flag ON
OCV_OPTION(OPENCV_GENERATE_PKGCONFIG "Generate .pc file for pkg-config build tool (deprecated)" OFF)
after install opencv4 successfully, you should add these envionment variables to your ~/.bashrc
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64
reference: https://docs.opencv.org/4.1.0/d7/d9f/tutorial_linux_install.html https://www.cnblogs.com/yuzhoumeigui/p/12568934.html
same issue
Same issue with Ubuntu 22.04
altair@altair:~/darknet$ make
gcc -Iinclude/ -Isrc/ -DOPENCV pkg-config --cflags opencv4
-Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV obj/captcha.o obj/lsd.o obj/super.o obj/art.o obj/tag.o obj/cifar.o obj/go.o obj/rnn.o obj/segmenter.o obj/regressor.o obj/classifier.o obj/coco.o obj/yolo.o obj/detector.o obj/nightmare.o obj/instance-segmenter.o obj/darknet.o libdarknet.a -o darknet -lm -pthread pkg-config --libs opencv4
-lstdc++ libdarknet.a
/usr/bin/ld: libdarknet.a(image.o): in function load_image': image.c:(.text+0x33d5e): undefined reference to
load_image_cv'
/usr/bin/ld: libdarknet.a(image.o): in function show_image': image.c:(.text+0x2dcc5): undefined reference to
show_image_cv'
/usr/bin/ld: obj/art.o: in function demo_art': art.c:(.text+0x51): undefined reference to
open_video_stream'
/usr/bin/ld: art.c:(.text+0x7f): undefined reference to get_image_from_stream' /usr/bin/ld: obj/segmenter.o: in function
demo_segmenter':
segmenter.c:(.text+0xcb5): undefined reference to open_video_stream' /usr/bin/ld: segmenter.c:(.text+0xd1e): undefined reference to
get_image_from_stream'
/usr/bin/ld: obj/regressor.o: in function demo_regressor': regressor.c:(.text+0xa77): undefined reference to
open_video_stream'
/usr/bin/ld: regressor.c:(.text+0xae7): undefined reference to get_image_from_stream' /usr/bin/ld: obj/classifier.o: in function
threat_classifier':
classifier.c:(.text+0x3ba5): undefined reference to open_video_stream' /usr/bin/ld: classifier.c:(.text+0x3c8a): undefined reference to
get_image_from_stream'
/usr/bin/ld: obj/classifier.o: in function gun_classifier': classifier.c:(.text+0x465d): undefined reference to
open_video_stream'
/usr/bin/ld: classifier.c:(.text+0x4715): undefined reference to get_image_from_stream' /usr/bin/ld: obj/classifier.o: in function
demo_classifier':
classifier.c:(.text+0x4964): undefined reference to open_video_stream' /usr/bin/ld: classifier.c:(.text+0x4a57): undefined reference to
get_image_from_stream'
/usr/bin/ld: obj/detector.o: in function test_detector': detector.c:(.text+0x2d24): undefined reference to
make_window'
/usr/bin/ld: obj/instance-segmenter.o: in function demo_isegmenter': instance-segmenter.c:(.text+0xdd5): undefined reference to
open_video_stream'
/usr/bin/ld: instance-segmenter.c:(.text+0xe3e): undefined reference to get_image_from_stream' /usr/bin/ld: libdarknet.a(demo.o): in function
fetch_in_thread':
demo.c:(.text+0x5c): undefined reference to get_image_from_stream' /usr/bin/ld: libdarknet.a(demo.o): in function
demo':
demo.c:(.text+0x84a): undefined reference to open_video_stream' /usr/bin/ld: demo.c:(.text+0x86a): undefined reference to
get_image_from_stream'
/usr/bin/ld: demo.c:(.text+0xbe5): undefined reference to open_video_stream' /usr/bin/ld: demo.c:(.text+0xc2d): undefined reference to
make_window'
collect2: error: ld returned 1 exit status
make: *** [Makefile:84: darknet] Error 1