You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xcode9.2编译报错:找不到-lopencv_core.3.3.1库,已装OpenCV3.4.0求助

Fixing "ld: library not found for -lopencv_core.3.3.1" in Xcode

Let’s work through this linker error — your hunch about version mismatch is totally correct. Here’s how to resolve it step by step:

1. Check for hardcoded version references in your project

First, double-check your Other Linker Flags in Xcode. If you’ve explicitly added -lopencv_core.3.3.1, that’s the root issue. Replace it with either:

  • -lopencv_core (uses the default symlinked version in your OpenCV install)
  • -lopencv_core.3.4.0 (matches your installed 3.4.0 version)

You can confirm the exact library filename by running this in Terminal:

ls /usr/local/Cellar/opencv/3.4.0_1/lib | grep opencv_core

You should see something like libopencv_core.3.4.0.dylib — use that version suffix if you go with the explicit flag.

2. Clean Xcode’s cached data

Xcode often holds onto old dependency paths or cached builds, which can cause issues even after you update settings. To fix this:

  • Open Xcode, go to Xcode > Preferences > Locations
  • Under Derived Data, click the arrow icon to open the folder
  • Delete the folder corresponding to your project
  • Quit and restart Xcode, then do a full clean (Cmd+Shift+K) before rebuilding

3. Verify your Library Search Paths and linked frameworks

Even though you’ve set the path, make sure:

  • Your Library Search Paths points directly to /usr/local/Cellar/opencv/3.4.0_1/lib (not just /usr/local/lib — symlinks can sometimes cause confusion)
  • In Linked Frameworks and Libraries, you’ve added the actual .dylib files from the 3.4.0_1 folder, not any leftover 3.3.1 files that might still be on your system

4. Hunt for leftover old OpenCV files

If uninstalling/reinstalling didn’t clear everything, check for residual 3.3.1 files:
Run this in Terminal to find all OpenCV core libraries:

find /usr -name "libopencv_core*.dylib" 2>/dev/null

If you see any files with 3.3.1 in the name, delete them (you’ll need sudo for system-level files):

sudo rm /path/to/libopencv_core.3.3.1.dylib

5. Check for third-party dependencies

If your project uses any external libraries or pods that depend on OpenCV 3.3.1, those could be forcing the linker to look for the old version. Double-check your Podfile or any imported frameworks to ensure they’re compatible with 3.4.0.

Give these steps a try — the most likely fix is updating the hardcoded linker flag and clearing Xcode’s cache. Let me know if you hit any snags!

内容的提问来源于stack exchange,提问作者Braandyy_

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:10:03