我正在尝试在mac(OS X 10.11.6)上安装OpenCV并使用xcode 7.3.1。
我也尝试过Macports和Homebrew来安装OpenCV,但仍然有同样的错误:
Undefined symbols for architecture x86_64:
"cv::String::deallocate()", referenced from:
cv::String::~String() in main-d4af45.o
cv::String::operator=(cv::String const&) in main-d4af45.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation).
在xcode中构建项目时,我将调试和发布的Header Search Paths的值设置为/ usr / local / include和Library Search Paths,以便调试和发布到/ usr / local / lib。其他连接体的标记是:-lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videoio -lopencv_videostab
当我在终端上运行main.cpp时,会发生相同的Undefined symbols
错误。
我的main.cpp:
#include <iostream>
#include <opencv2/opencv.hpp>
int main(int argc, const char * argv[]) {
std::cout << "OpenCV Version" << CV_VERSION << std::endl;
return 0;
}
我已经尝试将我的xcode“c ++标准库”从libc ++(支持C ++ 11的LLVM C ++标准库)更改为libstdc ++(GNU C ++标准库),但'unordered_map' file not found
和{{1} }错误发生,所以我坚持使用libc ++(支持C ++ 11的LLVM C ++标准库)。