2011-06-09 80 views
1

我编译的代码已经通过macports安装了opencv。但是,在运行我的生成文件时,我得到了在macports上用opencv编译代码

ld: warning: in /opt/local/lib/libopencv_core.dylib, file was built for unsupported file format which is not the architecture being linked (i386) 
ld: warning: in /opt/local/lib/libopencv_imgproc.dylib, file was built for unsupported file format which is not the architecture being linked (i386) 
ld: warning: in /opt/local/lib/libopencv_highgui.dylib, file was built for unsupported file format which is not the architecture being linked (i386) 
ld: warning: in /opt/local/lib/libopencv_ml.dylib, file was built for unsupported file format which is not the architecture being linked (i386) 
ld: warning: in /opt/local/lib/libopencv_video.dylib, file was built for unsupported file format which is not the architecture being linked (i386) 
ld: warning: in /opt/local/lib/libopencv_features2d.dylib, file was built for unsupported file format which is not the architecture being linked (i386) 
ld: warning: in /opt/local/lib/libopencv_calib3d.dylib, file was built for unsupported file format which is not the architecture being linked (i386) 
ld: warning: in /opt/local/lib/libopencv_objdetect.dylib, file was built for unsupported file format which is not the architecture being linked (i386) 
ld: warning: in /opt/local/lib/libopencv_contrib.dylib, file was built for unsupported file format which is not the architecture being linked (i386) 
ld: warning: in /opt/local/lib/libopencv_legacy.dylib, file was built for unsupported file format which is not the architecture being linked (i386) 
ld: warning: in /opt/local/lib/libopencv_flann.dylib, file was built for unsupported file format which is not the architecture being linked (i386) 

这是否意味着这些库都没有链接?我能做些什么呢?

回答

0

的问题是,你正在编译代码的一个架构(可能x86_64的即英特尔64位)和你问的MacPorts与i386架构来构建,即32位

所以哟需要改变一个或另一个。

1)更改你的代码 - 在编译规则中将-arch x86_64添加到gcc的选项中。

2)卸载macports,然后重新安装并在macports.conf文件中选择所需的build_arch,并检查默认情况下的universal_archs。

+0

奥普斯我想我知道什么是错的。在我的上层通用make文件中,有这两行:CFLAGS + = -arch i386 -arch x86_64 LDFLAGS + = -arch i386 -arch x86_64我删除了-arch i386 for both and it worked。谢谢! – 2011-06-16 18:42:03