gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 21:09:25 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com