OpenMP linker problem imwrite (Bug #219)
Description
Hello,
I have the following problem compiling a rather simple OpenCV application with GCC 4.3.2 under Debian GNU/Linux:
release/multi_img.o: In function @multi_img::write_out(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)': multi_img.cpp:(.text+0x3cd): undefined reference to @cv::imwrite(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Mat const&, std::vector<int, std::allocator<int> > const&)' multi_img.cpp:(.text+0x4cf): undefined reference to @cv::imwrite(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Mat const&, std::vector<int, std::allocator<int> > const&)'
I tried both OpenCV 2.0 release and current SVN (2894).
From various internet sources you get the recommendation to use -DGLIBCXX_PARALLEL. The claim is that the OpenMP-enabled build of OpenCV uses a parallelized version of std::vector which then clashes with the non-parallelized version in the application at linking time.
It is true that this option is needed to compile and successfully link with HoG features. Unfortunately, it does not help with the imwrite problem in my case. As a side note, the GLIBCXX_PARALLEL option also has problems with the BOOST libraries, which at the current date are incompatible to the parallelized std containers.
The problem does not occur when OpenMP is disabled while building OpenCV. The difference is obvious when looking into the library:
objdump -TC with-openmp/libhighgui.so | grep imwrite 000170c0 g DF .text 0000002b Base cv::imwrite(std::string const&, cv::Mat const&, std::+cxx1998::vector<int, std::allocator<int> > const&) 00018e60 g DF .text 0000002b Base objdump -TC without-openmp/libhighgui.so | grep imwrite cv::imwrite(std::string const&, cv::Mat const&, std::vector<int, std::allocator<int> > const&)
This problem is not new. Last bug entry is here:
http://sourceforge.net/tracker/index.php?func=detail&aid=2891137&group_id=22870&atid=376677
There a fix in SVN is claimed. However, this problem still occurs with current SVN version.
Possible solution to the problem:
I assume the source of the problem is that it is never explicitely stated which version of std::vector to use. Instead, when OpenMP is enabled, OpenCV is compiled with GLIBCXX_PARALLEL define. OpenCV should not use the parallelized stdlib except for internal use where it fits (how to do that see PDF link below).
See http://algo2.iti.kit.edu/singler/mcstl/iwmse06-singler.pdf for details.
Associated revisions
Merge pull request #219 from kirill-kornyakov/hack-hough-lines-sanity-test-on-win32
Ugly hack to make HoughLines sanity check pass on Windows
History
Updated by anonymous - almost 15 years ago
OpenMP is no longer used in OpenCV SVN (we switched to TBB), so the reported problem should automatically be resolved.
- Status changed from Open to Done
- (deleted custom field) set to fixed
Updated by Andrey Kamaev over 12 years ago
- Status changed from Done to Cancelled