Reputation: 397
So I've written some very basic OpenCV C++ code to test it's functionality. I am using CodeBlocks on Linux Ubuntu 16.04. I have installed OpenCV correctly, I think, Codeblocks offers 'OpenCV Project' as an option when making a project and whenever I start typing in an OpenCV keyword, it'll expand and suggest keywords.
My problem is that when I attempt to build it, I get
undefined reference to `cv::imread(std::__cxxll::basic_string<char, std::char_traits<ch..
And it repeats this for every opencv function.
I read somewhere that this may have something to do with the archive files and so I'll provide the results when I enter:
pkg-config opencv --libs
into the terminal. The output is:
-L/usr/local/lib -lopencv_calib3d -lopencv_contrib -lopencv_core
-lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui
-lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree
-lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching
-lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab -latomic
-ltbb -lGL -lGLU -lrt -lpthread -lm -ldl
So how can I solve this issue? Should I edit my files in some way?
Thanks very much in advance
Upvotes: 0
Views: 1540
Reputation: 147
Your code has been compiled with a standard library using the std::__cxx11 namespace. Ie, you're probably using g++ 5+ which has a different ABI to previous versions. The opencv libraries you've installed are probably an older ABI, and therefore not compatible.
You can either compile the opencv libraries yourself, use an earlier compiler that matches the ABI of the libries you have, or configure your compiler to use the old ABI.
You can use the macro _GLIBCXX_USE_CXX11_ABI if you're using g++ 5. Before you include and std libs:
#define _GLIBCXX_USE_CXX11_ABI 0
Upvotes: 3