0

Mac で OpenCV のビルドに成功しましたが、XCode で単純な OpenCV プロジェクトをコンパイルできませんでした。

プロジェクトのファイル グループに libopencv_core、libopencv_highgui、libopencv_imgproc を追加しました。

リンカーの出力は次のとおりです。

/Users/petilodie/Library/Developer/Xcode/DerivedData/opencv_test-fylvojzfgmnpmycaxkpiajicbmii/Build/Products/Debug/opencv_test normal x86_64
    cd /Users/petilodie/Projects/Test/opencv_test
    setenv MACOSX_DEPLOYMENT_TARGET 10.8
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/petilodie/Library/Developer/Xcode/DerivedData/opencv_test-fylvojzfgmnpmycaxkpiajicbmii/Build/Products/Debug -F/Users/petilodie/Library/Developer/Xcode/DerivedData/opencv_test-fylvojzfgmnpmycaxkpiajicbmii/Build/Products/Debug -filelist /Users/petilodie/Library/Developer/Xcode/DerivedData/opencv_test-fylvojzfgmnpmycaxkpiajicbmii/Build/Intermediates/opencv_test.build/Debug/opencv_test.build/Objects-normal/x86_64/opencv_test.LinkFileList -mmacosx-version-min=10.8 -o /Users/petilodie/Library/Developer/Xcode/DerivedData/opencv_test-fylvojzfgmnpmycaxkpiajicbmii/Build/Products/Debug/opencv_test

Undefined symbols for architecture x86_64:
  "_cvDestroyWindow", referenced from:
      _main in main.o
  "_cvLoadImage", referenced from:
      _main in main.o
  "_cvNamedWindow", referenced from:
      _main in main.o
  "_cvReleaseImage", referenced from:
      _main in main.o
  "_cvShowImage", referenced from:
      _main in main.o
  "_cvWaitKey", 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)

main.cpp のコードは次のとおりです。

#include <iostream>
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"

int main(int argc, const char * argv[])
{
    IplImage* img = cvLoadImage( argv[1] );
    cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
    cvShowImage( "Example1", img );
    cvWaitKey(0);
    cvReleaseImage( &img );
    cvDestroyWindow( "Example1" );
}

それで、ここで何が問題なのですか?

4

1 に答える 1

0

ライブラリをバイナリにリンクする必要があります。

ビルド設定

于 2012-08-05T00:19:19.470 に答える