我在运行 Lion 的 Macbook 上本地构建了 OpenCV 的 i386 风格,方法是使用
cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=i386 -D CMAKE_C_FLAGS=-m32 -D CMAKE_CXX_FLAGS=-m32 ..
make -j8
sudo make install
库构建和发布都很好,我已将它们添加到我的 xcode 项目中。 但是,在构建我的测试应用程序时出现链接错误,它们似乎是名称修改问题。
Undefined symbols for architecture i386:
"cv::namedWindow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
_main in main.o
"cv::imread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
_main in main.o
"cv::imshow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cv::_InputArray const&)", referenced from:
_main in main.o
以cv::imread为例,从libopencv_highgui.dylib导出,名称为:
00007510 (__TEXT,__text) external __ZN2cv6imreadERKSsi
当 main.o 引用符号时
U __ZN2cv6imreadERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEi
另一方面,函数__ZN2cv7waitKeyEi
来自相同的 dylib 链接很好。
测试应用程序和框架均适用于 i386 arch。
有什么可能导致此问题的想法吗?
最佳答案
我遇到了同样的问题。我认为问题可能是如果您使用了 the MacPorts编译您的 OpenCV 库,它们可能是由 GCC 根据 it's Portfile 构建的.我将 XCode (Apple LLVM 4.1) 中使用的编译器切换到 LLVM GCC 4.2,现在它可以工作了。
希望对您有所帮助。
关于xcode - OpenCV 未解析的符号 - 名称修改不匹配 - xcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13461400/