Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to 'cv::String::allocate(unsigned long)' #8

Open
TLMichael opened this issue Jun 25, 2018 · 10 comments
Open

undefined reference to 'cv::String::allocate(unsigned long)' #8

TLMichael opened this issue Jun 25, 2018 · 10 comments

Comments

@TLMichael
Copy link

cvcamera.o: In function cv::String::String(char const*)': /usr/local/include/opencv2/core/cvstd.hpp:602: undefined reference to cv::String::allocate(unsigned long)'
Makefile:268: recipe for target 'VideoTol' failed
cvcamera.o: In function cv::String::~String()': /usr/local/include/opencv2/core/cvstd.hpp:648: undefined reference to cv::String::deallocate()'
cvcamera.o: In function cv::Mat::Mat(int, int, int, void*, unsigned long)': /usr/local/include/opencv2/core/mat.inl.hpp:500: undefined reference to cv::error(int, cv::String const&, char const*, char const*, int)'
/usr/local/include/opencv2/core/mat.inl.hpp:516: undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
collect2: error: ld returned 1 exit status

@TLMichael
Copy link
Author

All right. I solved this.
By LIBS += -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_videoio LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui

@LinusLogicsTechnologies

All right. I solved this.
By LIBS += -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_videoio LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui

Hi Michael
Can you provide the full make script to compile opencv with .cu file

@zongoalbert
Copy link

could you explain please @TLMichael , write full command line please

@TLMichael
Copy link
Author

Hi guys,

I'm sorry I couldn't remember all the details,
since the last time I dealt with this problem was two years ago.

I compiled my project with OpenCV lib and Darknet lib (which can be compiled with CUDA itself).

For .pro file and other details you can refer to my project

Best,
Michael.

@TNemes-3141
Copy link

Hi, where do you have to add the dependencies? In the source file, the CMakeLists.txt or elsewhere? I have to deal with similar issues:

CMakeFiles/main.dir/src/Main.cpp.o: In function `cv::String::~String()':
/usr/include/opencv2/core/cvstd.hpp:648: undefined reference to `cv::String::deallocate()'
CMakeFiles/main.dir/src/Main.cpp.o: In function `cv::String::operator=(cv::String const&)':
/usr/include/opencv2/core/cvstd.hpp:656: undefined reference to `cv::String::deallocate()'
CMakeFiles/main.dir/src/Main.cpp.o: In function `cv::Mat::~Mat()':
/usr/include/opencv2/core/mat.inl.hpp:692: undefined reference to `cv::fastFree(void*)'
CMakeFiles/main.dir/src/Main.cpp.o: In function `cv::Mat::release()':
/usr/include/opencv2/core/mat.inl.hpp:804: undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
CMakeFiles/main.dir/build.make:94: recipe for target 'main' failed
make[2]: *** [main] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/main.dir/all' failed
make[1]: *** [CMakeFiles/main.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

@csverma610
Copy link

I solved it by adding -fPIC in CPPFLAGS.

@liz821
Copy link

liz821 commented Oct 29, 2020

Hi, where do you have to add the dependencies? In the source file, the CMakeLists.txt or elsewhere? I have to deal with similar issues:

CMakeFiles/main.dir/src/Main.cpp.o: In function `cv::String::~String()':
/usr/include/opencv2/core/cvstd.hpp:648: undefined reference to `cv::String::deallocate()'
CMakeFiles/main.dir/src/Main.cpp.o: In function `cv::String::operator=(cv::String const&)':
/usr/include/opencv2/core/cvstd.hpp:656: undefined reference to `cv::String::deallocate()'
CMakeFiles/main.dir/src/Main.cpp.o: In function `cv::Mat::~Mat()':
/usr/include/opencv2/core/mat.inl.hpp:692: undefined reference to `cv::fastFree(void*)'
CMakeFiles/main.dir/src/Main.cpp.o: In function `cv::Mat::release()':
/usr/include/opencv2/core/mat.inl.hpp:804: undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
CMakeFiles/main.dir/build.make:94: recipe for target 'main' failed
make[2]: *** [main] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/main.dir/all' failed
make[1]: *** [CMakeFiles/main.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

have you solved it?
and how?

@nguyencanhtrung
Copy link

For my case:
adding followings to my linker solved the problem
-lopencv_videoio -lopencv_imgcodecs -lopencv_core -lopencv_imgproc -lopencv_features2d -lopencv_flann -lopencv_video -lopencv_calib3d -lopencv_highgui

@UtsaChattopadhyay
Copy link

For my case: adding followings to my linker solved the problem -lopencv_videoio -lopencv_imgcodecs -lopencv_core -lopencv_imgproc -lopencv_features2d -lopencv_flann -lopencv_video -lopencv_calib3d -lopencv_highgui

I am using android studio, can you help me know where can i find the linker? I am quite new to this, sorry

@KingfaLuis
Copy link

undefined reference to `cv::String::allocate(unsigned long)'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants