tags:

views:

321

answers:

4

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++ -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

Any ideas on how to get past this?

Thanks!

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

A: 

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.

Chuck
Do you know of an easy way to adjust the opencv compilation step to tell it to compile for 64 bit? (I assume that is the issue?).
Hortitude
You can verify the architectecture of your library with the lipo command. (lipo -info /path/to/library) I think that "file" will give you this information too.
Dan
A: 

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.

Stephen Canon
A: 

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

Ugh....

Hortitude
A: 

Hi,

I think you get your problems solved with this tip or the provided binary here:

http://giesler.biz/~bjoern/blog/?p=183

Christoph