Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Sudden linker error with GCC 5.2.0

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

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

Any idea what could cause that?