雪豹上的dylib“文件不是必需的架构”

时间:2010-02-24 00:51:16

标签: c++ macos opencv

我已经在snow leopard上编译了opencv并且它说它编译正确,但是当我尝试编译我的示例程序时,我输出如下:

g++ -o tm_scons template.o -L/opencv/opencv/build/lib -lcxcore -lcv -lcvaux -lhighgui -lml
ld: warning: in /opencv/opencv/build/lib/libcxcore.dylib, file is not of required architecture
ld: warning: in /opencv/opencv/build/lib/libcv.dylib, file is not of required architecture
ld: warning: in /opencv/opencv/build/lib/libcvaux.dylib, file is not of required architecture
ld: warning: in /opencv/opencv/build/lib/libhighgui.dylib, file is not of required architecture
ld: warning: in /opencv/opencv/build/lib/libml.dylib, file is not of required architecture

这可能是我编译OpenCV或使用它的应用程序的问题吗?

3 个答案:

答案 0 :(得分:0)

正确编译并不意味着要编译您现在要编译的任何架构。很可能这个库被编译为32位,你编译为64位,反之亦然。

答案 1 :(得分:0)

很可能你的程序是64位编译的(SnowLeopard上的默认行为),并且库是32位编译的。在构建程序时尝试将-m32-arch i386标志添加到编译器中,并查看链接是否有效。

答案 2 :(得分:0)

事实证明,魔术是使用-m32并切换到/usr/bin/g++-4.0编译器。

...唉