Using Open CV with Netbeans 8 on Windows
I have followed the instructions to set up OpenCv from this document and I am trying to use the pre-built libraries with netbeans and the MinGW tool collection.
My simple C++ OpenCV program sees the headers / includes for: opencv2/core/core.hpp
and opencv2/highgui/highgui.hpp
without any compiler flags.
However I get the following errors from the build:
g++ -m64 -o dist/Debug/MinGW-Windows/opencvtester build/Debug/MinGW-Windows/main.o -LC:\Tools\opencv\build\x64\vc12/temp/lib -lopencv_core2411d -lopencv_highgui2411d -lopencv_legacy2411d -lopencv_ml2411d
C:\Dev\opencvtester/main.cpp:13: undefined reference to `cv::Mat::Mat(_IplImage const*, bool)'
C:\Dev\opencvtester/main.cpp:21: undefined reference to `cv::namedWindow(std::string const&, int)'
C:\Dev\opencvtester/main.cpp:22: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Dev\opencvtester/main.cpp:22: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
C:\Dev\opencvtester/main.cpp:24: undefined reference to `cv::waitKey(int)'
When I remove the netbeans reference to the link library, I get different errors:
c:/Tools/qt/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_core2411d
c:/Tools/qt/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_highgui2411d
c:/Tools/qt/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_legacy2411d
c:/Tools/qt/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_ml2411d
So I assume the build is finding the library files in opencv/build/x64/vc10/bin but somehow not finding the above references.
I would be grateful if someone could point me at the next steps to take.
Thanks.
Have you included the headers? I know that under VS you shall include also the ...\opencv\includes\opencv2 folder or under Linux the /usr/local/include/opencv2, so I suppose you shall add the headers folder somewhere, too
I have the Includes in the C++ for opencv2/core/core.hpp and opencv2/highgui/highgui.hpp. and for the compile, I include C:/Tools/opencv/build/include. On the link I include ${OPENCV_DIR}/lib where OPENCV_DIR is: C:\Tools\opencv\build\x64\vc12
Shouldn't be bin there,
${OPENCV_DIR}/bin
?Thanks for your reply. I removed the \bin and still got the same undefined error messages. I also tried with a filename which doesn't exist and then get the messages described above, e.g. cannot find -lopencv_core2411d.. It appears to be finding the library files but is then unable to find the references within them.
you can't use the prebuilt vs libs with mingw.
you will have to build the opencv libs using cmake first (resulting in opencv_core2411.a, etc, then try again with those.
I was gradually coming to that conclusion. I also tried with Visual Studio 2013 and eventually discovered that it also isn't compatible with the released OpenCV libraries, so that requires a build as well.
Thanks for your help.