【问题标题】:OpenCV cvSmooth linker errorOpenCV cvSmooth 链接器错误
【发布时间】:2011-12-03 00:47:33
【问题描述】:

我正在使用 XCode 4 进行开发,并链接了 OpenCV 库以创建一些实验项目。

如果在编译此行时发现问题:

int main (int argc, const char * argv[])
{
    IplImage* img = cvLoadImage( argv[1]);
    cvNamedWindow( "Example3-in" );
    cvNamedWindow( "Example3-out" );

    // Show the original image
    cvShowImage("Example3-in", img);

    // Create an image for the output
    IplImage* out = cvCreateImage( cvGetSize(img), IPL_DEPTH_8U, 3 );

    // Perform a Gaussian blur
    cvSmooth( img, out, CV_GAUSSIAN, 11, 11 );

    // Show the processed image
    cvShowImage("Example3-out", out);

    cvWaitKey(0);
    cvReleaseImage( &img );
    cvReleaseImage( &out );
    cvDestroyWindow( "Example3-in" );
    cvDestroyWindow( "Example3-out" );
    return 0;
}

问题:

Undefined symbols for architecture x86_64:
  "_cvSmooth", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

在我看来,就像这些库不是针对 64 位架构编译的...

注意:

通过 MacPorts 安装的库

【问题讨论】:

    标签: c++ compiler-construction xcode4 opencv linker


    【解决方案1】:

    我的系统上安装的是 x86_64。我下载了源代码并自己编译。

    我打算建议另一种选择:强制 XCode 构建 i386,但似乎 it's not possible

    但是,您可以通过 cmd-line 强制编译为 i386:

    g++ main.cpp -o app `pkg-config --cflags --libs opencv` -m32 -arch i386
    

    请记住,您的应用程序链接到的所有库都需要具有相同的架构。

    【讨论】:

    • 架构 i386 的未定义符号,我认为该库是通过 MacPorts 为 64 位架构 (iMac) 安装的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-19
    • 2015-04-04
    • 1970-01-01
    • 2017-06-20
    • 2018-04-16
    • 2017-02-28
    • 2019-12-17
    相关资源
    最近更新 更多