写了一学期py-opencv了都快结束了突然又要折腾起c++下来,真实给自己跪了,不过环境基本都搞定了,中间碰到了一些问题这里总结一下:
- usr/local/include和usr/local/lib的问题就不说了,编译之前要把头文件和动态库都连进去否则会产生dyld: Library not loaded的错误
- dyld: Library not loaded: cv2.so,有放到cv2.so檔案的, 則是要記得到Build Phases(project target下)內,把選項改為optional
- Undefined symbols for architecture x86_64:
"cv::namedWindow(std::__1::basic_string, std::__1::allocator > const&, int)", referenced from:
_main in main.o
"cv::imread(std::__1::basic_string, std::__1::allocator > const&, int)", referenced from:
_main in main.o
"cv::imshow(std::__1::basic_string, std::__1::allocator > const&, cv::_InputArray const&)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
C++库和opencv库编译不一致,将XCode的C++ Standard Library改为GNU C++ standard library即可正常编译显示图片。Project Build settings -> APPLE LLVM compiler 4.2 - Language -> C++ Standard Library