I am building a project using Opencv 3.1 and wxwidgets 3.1. The code I use: [wxOpenCv Demo1]
I try to add a write frame object, using the function cv::imwrite(). (I changed the c calls to c++ eg: cvQueryFrame( m_pCapture ) to m_pCapture >> m_CurFrame;)
I get this error:
Undefined symbols for architecture x86_64:
"cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector > const&)", referenced from:
CCamera::SaveFrame() in camera.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Without wxwidgets the opencv functions work fine. So its seems that it has to do with the combination of wxwidgets and opencv.
This works fine with wxwidgets and Opencv:
cv::imshow("tmp",m_CurFrame);
cv::waitKey(4);
// cv::imwrite(Tmp , m_CurFrame);
If I uncomment the last line, I get the error.
OS X: 10 Yosemite and I use the default compiler (Apple LLVM 7.0)
I have no idea what to do about this!
solved the problem (and more) by recompiling wxwidgets 3.1.0 and Opencv 3.1. I used these links to get it going.
Small guide to compiling wxWidgets, Opencv against C++ 11:
Compile wxwidgets 3.1.0: I followed the install.txt for OSX. And tweaked the ../configure call with help from this
I added: --enable-debug
and changed the macosx version
../configure --disable-shared --enable-debug --enable-unicode --with-cocoa --with-macosx-version-min=10.7 --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk CXXFLAGS="-std=c++0x -stdlib=libc++" CPPFLAGS="-stdlib=libc++" LIBS=-lc++
Then with the help of this page I build a xcode project. Tweaking a few things: (wxcocoa.xcodeproj and minimal.xcodeproj, and a all new projects)
$(WXROOT)/build/osx
(to find wx.xcconfig)GNU 11
(not sure if this is right)GNU++11 [-std=gnu++11]
libc++ (LLVM C++ standard library with C++ 11 support)
MACOSX_DEPLOYMENT_TARGET = 10.10
libwx_osx_cocoa_static.a
to: lwx_osx_cocoa_static.a
(why, I do not know)I use GNU++ 11 and thus libc++ to be able to use new functionality like “future" I then added OpenCV to my newly created wxXcode project:
The compiler settings same as for wxWidgets (see above)
(added:) To do this I added some lines to the CMakeLists.txt
in the (Opencv-master folder). Below the line: # OpenCV compiler and linker options
(I found this trick here: search the web for: OpenCV with C++11 on OS X 10.8
message("Setting up Xcode for C++11 with libc++.") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++0x") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
Then follow this page to update the newly created wxWidgets xcode project (search the web for: howto-setup-xcode-6-1-to-work-with-opencv-libraries)
This should do the trick! I can now combine wxWidgets, OpenCV and the libc++ (multithreading, “future")
I hope this helps. Please let me know if you found out more!