在macports上用opencv编译代码

时间:2011-06-09 21:41:00

标签: opencv makefile

我已经使用通过macports安装的opencv编译代码。但是,在运行我的makefile时,我得到了

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)

这是否意味着图书馆都没有链接?我该怎么办?

1 个答案:

答案 0 :(得分:0)

问题是您正在编译一个架构的代码(可能是x86_64,即Intel 64位),并且您要求使用i386架构构建macport,即32位

所以你需要改变其中一个。

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

2)卸载macports然后重新安装并在macports.conf文件中选择所需的build_arch,并检查应该默认为两者的universal_archs。