xcode - OpenCV 未解析的符号 - 名称修改不匹配 - xcode

标签 xcode opencv name-mangling

我在运行 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/

相关文章:

opencv - HoughCircles 识别球的参数

c++ - C++中extern "C"的作用是什么?

swift - 导入框架后,我没有看到任何命令

IOS - 将核心数据加载到 TableView 时,AnyObject 不能转换为字符串?

c++ - 为什么我在 opencv 3.0 beta 中找不到 balanceWhite?

opencv - 在Ubuntu服务器11.10上安装OpenCV预构建库

ruby - 安装 Ruby 后 MAC OS X 上的事件开发者路径无效

ios - “~/Library/Developer/Xcode/iOS DeviceSupport” 处缺少 iOS 符号

c++ - 为什么 gcc 和 clang 为函数模板的实例化生成不同的符号名称?

Python 名称修改允许双向访问