xcode - OSX 10.7.5 + OpenCV 2.4.3 : "Undefined symbols for architecture x86_64" when using "cv::SimpleBlobDetector"

标签 xcode opencv osx-lion

我想尝试一下 OpenCV cv::SimpleBlobDetector ,但是在编译我的代码时出现以下错误:

Ld /Users/dom/Library/Developer/Xcode/DerivedData/blob-test-opencv-dgtflkyexnsjekbwuxnuoisqknux/Build/Products/Debug/blob-test-opencv.app/Contents/MacOS/blob-test-opencv normal x86_64
    cd /Users/dom/Desktop/blob-test-opencv
    setenv MACOSX_DEPLOYMENT_TARGET 10.7

    /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/dom/Library/Developer/Xcode/DerivedData/blob-test-opencv-dgtflkyexnsjekbwuxnuoisqknux/Build/Products/Debug \
    -L/usr/local/Cellar/opencv/2.4.3/lib \
    -F/Users/dom/Library/Developer/Xcode/DerivedData/blob-test-opencv-dgtflkyexnsjekbwuxnuoisqknux/Build/Products/Debug \
    -filelist /Users/dom/Library/Developer/Xcode/DerivedData/blob-test-opencv-dgtflkyexnsjekbwuxnuoisqknux/Build/Intermediates/blob-test-opencv.build/Debug/blob-test-opencv.build/Objects-normal/x86_64/blob-test-opencv.LinkFileList \
    -mmacosx-version-min=10.7 \
    -fobjc-arc \
    -fobjc-link-runtime \
    -stdlib=libc++ \
    -lopencv_calib3d.2.4.3 \
    -lopencv_contrib.2.4.3 \
    -lopencv_core.2.4.3 \
    -lopencv_features2d.2.4.3 \
    -lopencv_flann.2.4.3 \
    -lopencv_gpu.2.4.3 \
    -lopencv_highgui.2.4.3 \
    -lopencv_imgproc.2.4.3 \
    -lopencv_legacy.2.4.3 \
    -lopencv_ml.2.4.3 \
    -lopencv_nonfree.2.4.3 \
    -lopencv_objdetect.2.4.3 \
    -lopencv_photo.2.4.3 \
    -lopencv_stitching.2.4.3 \
    -lopencv_ts.2.4.3 \
    -lopencv_video.2.4.3 \
    -lopencv_videostab.2.4.3 \
    -framework Cocoa -o /Users/dom/Library/Developer/Xcode/DerivedData/blob-test-opencv-dgtflkyexnsjekbwuxnuoisqknux/Build/Products/Debug/blob-test-opencv.app/Contents/MacOS/blob-test-opencv

Undefined symbols for architecture x86_64:
  "cv::drawKeypoints(cv::Mat const&, std::__1::vector<cv::KeyPoint, std::__1::allocator<cv::KeyPoint> > const&, cv::Mat&, cv::Scalar_<double> const&, int)", referenced from:
      BlobTest::detectBlobs(cv::Mat) in blob-detector.o
  "cv::FeatureDetector::detect(cv::Mat const&, std::__1::vector<cv::KeyPoint, std::__1::allocator<cv::KeyPoint> >&, cv::Mat const&) const", referenced from:
      BlobTest::detectBlobs(cv::Mat) in blob-detector.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我编写的代码如下所示:

cv::SimpleBlobDetector::Params params;

params.minDistBetweenBlobs = 10.0;
params.filterByArea = true;
params.minArea = 500.0;
params.maxArea = 1500.0;

cv::SimpleBlobDetector myBlobDetector( params );
std::vector<cv::KeyPoint> myBlobs;

myBlobDetector.detect( image, myBlobs );

cv::Mat blobImg;
cv::drawKeypoints( image, myBlobs, blobImg );

我的 header 前缀文件包含 OpenCV:

#ifdef __cplusplus
    #import "opencv2/opencv.hpp"
#endif

我在 OSX 10.7.5 上运行 Xcode 4.52 和 OpenCV 2.43(通过brew)。

据我所知,所有必需的库都已正确链接(尤其是 opencv_features2d.2.4.3),并且 OpenCV 是为我的 64 位系统编译的。其他 OpenCV 代码一直工作正常……我错过了什么吗?

最佳答案

在 xcode 的左侧,选择您的项目名称。在右侧窗口中,转到

Buil Settings>Build Options> Compiler for C/C++/Objective-C

将其从 Apple LLVM 编译器 更改为 LLVM GCC 4.2

干杯,

雷扎

关于xcode - OSX 10.7.5 + OpenCV 2.4.3 : "Undefined symbols for architecture x86_64" when using "cv::SimpleBlobDetector",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13564289/

相关文章:

iphone - Xcode 在您的钥匙串(keychain)中找不到此配置文件的有效私有(private)证书/有效 key 对

iphone - svn 更新未声明标识符后的 S3TransferManager

ios - 设置默认 "iPhone Developer"证书在 XCode/Keychain 的 "Automatic Profile Selector"中选择

xcode - iOS 10/XCode 8的运行时问题

python - OpenCV 3 在 37% 时构建问题?

python - 为什么在使用 imshow 显示时使用 np.hstack 对图像进行零填充会使图像变白?

python-2.7 - 使用Python查找blackpixels的平均位置

ruby-on-rails - Cucumber 将 pdf 读入临时文件

ruby - 如何在 Mac OS X Lion 上使用 rvm 安装 Maglev?

python - Lion 上的 py2app 正在创建没有 python 框架或资源的空应用程序