0

I am using OpenCV in a project and up to GCC 5.1.0 I had no problems.

Suddenly, after installing GCC 5.2.0 (from source) I get a linker error for some of the OpenCV functions. The majority seems to work. Only the cs::im* functions seem to cause problems.

CMakeFiles/2DSIL.dir/main.cpp.o: In function `main':
/home/c7031105/Dropbox/2DSIL/main.cpp:35: undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/home/c7031105/Dropbox/2DSIL/main.cpp:110: undefined reference to `cv::imwrite(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
CMakeFiles/2DSIL.dir/V4.cpp.o: In function `V4::getWeights(std::vector<int, std::allocator<int> >, double&)':
/home/c7031105/Dropbox/2DSIL/V4.cpp:313: undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
CMakeFiles/2DSIL.dir/V4.cpp.o: In function `V4::compare(std::vector<int, std::allocator<int> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/home/c7031105/Dropbox/2DSIL/V4.cpp:110: undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
CMakeFiles/2DSIL.dir/V4.cpp.o: In function `V4::getWeights(cv::Mat, cv::Mat, double&)':
/home/c7031105/Dropbox/2DSIL/V4.cpp:352: undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/home/c7031105/Dropbox/2DSIL/V4.cpp:379: undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
CMakeFiles/2DSIL.dir/V4.cpp.o: In function `V4::compare(cv::Mat, cv::Mat, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/home/c7031105/Dropbox/2DSIL/V4.cpp:179: undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
CMakeFiles/2DSIL.dir/V4.cpp.o: In function `void cv::Mat::push_back<int>(int const&)':
/usr/local/include/opencv2/core/mat.hpp:689: undefined reference to `cv::Exception::Exception(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
CMakeFiles/2DSIL.dir/img_read_write.cpp.o: In function `dsil::visualize(cv::Mat const&, int)':
/home/c7031105/Dropbox/2DSIL/img_read_write.cpp:91: undefined reference to `cv::namedWindow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/home/c7031105/Dropbox/2DSIL/img_read_write.cpp:92: undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
CMakeFiles/2DSIL.dir/img_read_write.cpp.o: In function `dsil::imgwrite(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Mat const&)':
/home/c7031105/Dropbox/2DSIL/img_read_write.cpp:49: undefined reference to `cv::imwrite(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status
make[3]: *** [2DSIL] Error 1
make[2]: *** [CMakeFiles/2DSIL.dir/all] Error 2
make[1]: *** [CMakeFiles/2DSIL.dir/rule] Error 2
make: *** [2DSIL] Error 2

Does anyone know what the problem could be?

Plankalkül
  • 833
  • 8
  • 21
  • 1
    Because of duplicate: I am working on this project for over a year now and I never had any linking errors. So I am not really sure some general advice of what to do when linking fails is going to help me? As I said: It compiles and links without any problem with all GCCs up to 5.1 and suddenly breaks with GCC 5.2.0 – Plankalkül Sep 09 '15 at 20:59
  • OK, so I "solved" the problem by building the new OpenCV 3.0 library from source. Still would be interesting to know why that was necessary. – Plankalkül Sep 10 '15 at 09:24
  • 1
    After reading a bit I assume the reason is that with GCC 5.2.0 a new ABI is activated by default. From the GCC release notes: The old ABI is still supported and can be used by defining the macro _GLIBCXX_USE_CXX11_ABI to 0 before including any C++ standard library headers. So maybe that will be of help to someone else. – Plankalkül Sep 10 '15 at 10:55

0 Answers0