Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I'm programming simple apps that work with OpenCV.
My problem is that when I compile any code that uses the cv::findContours(), cv::drawContours, cv::imwrite() or any of the functions that have a vector<> as parameter, the linker throws me an "undefined reference" error for the function.
I have checked eveything I can, such as:
1) Correct declaration of parameters and calling of the functions.
2) Checked that the functions are declared on the OpenCV headers and defined in the source code.
3) I even made an objdump of the .so files to see if the functions were compiled in.
This is one of the apps that are causing me trouble:
The output of the command "nm -DC /usr/lib/libhighgui.so | grep imwrite" is:
00017850 T cv::imwrite(std::string const&, cv::Mat const&, std::__cxx1998::vector<int, std::allocator<int> > const&)
I dunno what is the std::__cxx1998::vector... stuff.. I assume it's a gcc notation for the 1998 corrections of the language.. I'm beggining to suspect that it has something to do with the vector parameters, as all of the functions that my apps do not link have some vector<> as parameter (findContours, imwrite). The strange thing is that I have no problem using split(Mat &, vector<Mat> &)..
I have no clue of why i'm having a problem only with some of the functions when the others work just fine..
Evo, If you dont mind me asking, which version of OpenCV are you using? I'm on version 2.0.0-r1.. Thanks
I have the 2.0.0-4 version in Debian unstable. I'm not sure exactly what upstream version that corresponds to, since the changelog.gz refers to another log file which seems not to be included in the package.
Thanks for your hint. I thought that it is impossible that I link the wrong libraries, since it is the first time I am working with OpenCV and therefore have only one version istalled.
But you were right! I was linking the libraries in C:\OpenCV2.1\bin, and there were really some libraries with the correct name in this directory, but not the ones that I compiled myself (file creation timestamp was too old).
Finally I found that my compiled libs were going to C:\OpenCV2.1\CMakeFiles\bin (This depends on your actual CMake configuration!). Now linking to this directory, it works fine :-)
Also I hope I won't be banned now since I am working on windows...
I was cheering too soon...
Although compilation and linking do not produce an error message anymore, I have now the following problem:
As soon as I try to open a named window (e.g. cv::namedWindow("Display", CV_WINDOW_AUTOSIZE) the application crashes (Application has encountered a problem and needs to close...). But, surprisingly, the Window is opening with the correct name "Display" before the application crashes!
Other functions of the OpenCV library seem to work, e.g. creating a cv::Mat and then loading an image to it by imread(argv, 1);
Is this another linker problem? Unfortunately when debugging in Eclipse, I can only see that it crashes at the namedWindow function call, but I cannot jump into it (but anyway I am not sure if that would be of any help to me...)
Here is what Dependency Walker outputs when profiling the crashing application:
GetProcAddress(0x75250000 [MSCTFIME.IME], "ImeGetImeMenuItems") called from "IMM32.DLL" at address 0x76337354 and returned NULL. Error: The procedure was not found (127).
GetProcAddress(0x75250000 [MSCTFIME.IME], "CtfImeInquireExW") called from "IMM32.DLL" at address 0x76337394 and returned 0x75269548.
GetProcAddress(0x75250000 [MSCTFIME.IME], "CtfImeSelectEx") called from "IMM32.DLL" at address 0x763373A8 and returned 0x752692C5.
GetProcAddress(0x75250000 [MSCTFIME.IME], "CtfImeEscapeEx") called from "IMM32.DLL" at address 0x763373BC and returned 0x752696FE.
GetProcAddress(0x75250000 [MSCTFIME.IME], "CtfImeGetGuidAtom") called from "IMM32.DLL" at address 0x763373D0 and returned 0x75269737.
GetProcAddress(0x75250000 [MSCTFIME.IME], "CtfImeIsGuidMapEnable") called from "IMM32.DLL" at address 0x763373E4 and returned 0x7526931A.
Second chance exception 0xC0000005 (Access Violation) occurred in "LIBHIGHGUI210.DLL" at address 0x6A3350C4.
Exited "TESTE.EXE" (process 0x98C) with code -1073741819 (0xC0000005).
I think I have now finally a working OpenCV environment (after hours and hours of trying all kind of stuff...)
In short, the solution was to use the gcc version 4.4.1, which I downloaded here: http://sourceforge.net/downloads/tdm...vious/1.908.0/
Download tdm-mingw-1.908.0-4.4.1-2.exe and install it. Do not use the web installer since this will download the latest version (which gave me the troubles described above).
Then compile OpenCV 2.1 as described in the instructions, using CMake etc.
After this I am now able to use the C interface (e.g. cvLoadImage) as well as the C++ interface (e.g. cv::imread).
When I tried to use the windows binarys (dll's) of the OpenCV library which can be downloaded from the OpenCV website (OpenCV-2.1.0-win32-vs2008.exe), I can use the C interface but not the C++ interface. Using the C++ interface will give a Linker error as described in my previous posts. I assume this is due to some incompatible name mangling for the C++ functions in the dlls.
When I compiled OpenCV 2.1 with TDM-GCC 4.5, everything was compiling and linking fine, but the cv::namedWindow crashed everytime it was called! I assume this is a bug in OpenCV which is only visible with this new compiler.
I hope this helps some people so they do not have to go through all the frustration that I went through!
BTW, I am working with Eclipse Helios with CDT plugin, on Windows XP SP2.