Snow LeopardにOpenCVをインストールしたはいいが、
コンパイル時にアーキテクチャを指定しないと以下のエラーが出た。
$ g++ -g -Wall -o a.out obj/main.o -L/usr/local/lib -lcxcore -lcv -lcvaux -lml -lhighgui
ld: warning: in obj/main.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /usr/local/lib/libcxcore.dylib, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /usr/local/lib/libcv.dylib, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /usr/local/lib/libcvaux.dylib, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /usr/local/lib/libml.dylib, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /usr/local/lib/libhighgui.dylib, file was built for i386 which is not the architecture being linked (x86_64)
Undefined symbols:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
ld: warning: in obj/main.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /usr/local/lib/libcxcore.dylib, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /usr/local/lib/libcv.dylib, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /usr/local/lib/libcvaux.dylib, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /usr/local/lib/libml.dylib, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /usr/local/lib/libhighgui.dylib, file was built for i386 which is not the architecture being linked (x86_64)
Undefined symbols:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
obj/main.oや*.dylibのファイルは、x86_64にリンクされていてi386でビルドされいないと言われる。
Snow Leopardのデフォルトのコンパイラが64bitでx86_64であるからのようだ。
32bitまたはアーキテクチャをi386に指定して上げればよいだろう。
$ g++ -m32 -g -Wall -o a.out obj/main.o -L/usr/local/lib -lcxcore -lcv -lcvaux -lml -lhighgui
または、$ g++ -arch i386 -g -Wall -o a.out obj/main.o -L/usr/local/lib -lcxcore -lcv -lcvaux -lml -lhighgui
これでコンパイルできるはず。参考:
http://jijixi.azito.com/cgi-bin/diary/index.rb?date=20100505
http://www-utheal.phys.s.u-tokyo.ac.jp/~yuasa/wiki/index.php/MacOSX_Snow_Leopardでld:_symbol(s)_not_foundが出てしまう
0 件のコメント:
コメントを投稿