开发者

dylib on Snow Leopard "file is not of required architecture"

I have compiled opencv on snow leopard and it says it compiled correctly, however when I try to compile my sample program against it, I get output like:

g++ -开发者_JAVA百科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

Is this likely a problem with my compilation of OpenCV or of my app that is using it?


Compiling correctly does not mean compiling for whatever architecture you're trying to compile now. Most likely the library is compiled as 32-bit and you're compiling as 64-bit or vice-versa.


Most likely your program is compiled 64-bit (the default behavior on SnowLeopard) and the library is compiled 32-bit. Try adding the -m32 or -arch i386 flag to the compiler when you build your program and see if the link works.


As it turns out the magic was using -m32 and switching to the /usr/bin/g++-4.0 compiler.

Ugh....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜