【问题标题】:compiling code with opencv on macports在 macports 上使用 opencv 编译代码
【发布时间】:2011-06-09 21:41:00
【问题描述】:

我已经用通过 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)

这是否意味着所有库都没有链接?我该怎么办?

【问题讨论】:

    标签: opencv makefile


    【解决方案1】:

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

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

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

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

    【讨论】:

    • 哎呀,我想我知道出了什么问题。在我的上层通用 make 文件中,有这两行: CFLAGS += -arch i386 -arch x86_64 LDFLAGS += -arch i386 -arch x86_64 我删除了两者的 -arch i386 并且它有效。谢谢!
    猜你喜欢
    • 2014-08-27
    • 1970-01-01
    • 2012-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多