LoginSignup
8
6

More than 5 years have passed since last update.

【Mac OSX】C++でOpenCVを利用したソースコードのコンパイル

Last updated at Posted at 2015-06-28

test.cppというOpenCVを利用したC++のファイルをコンパイルする際のメモ。
環境としては、GCCの皮を被ったClangを使用。
OpenCVはHomebrewで導入。

$ g++ -o test test.cpp `pkg-config --cflags opencv` `pkg-config --libs opencv`
とりあえずこれで実行。

そしたら

ld: library not found for -llibtbb.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)

こんなんが出てきました。
しょうがないから以下のように編集して頑張りましょう。

/usr/local/lib/pkgconfig/opencv.pc
を開いて
-llibtbb.dylib の部分を
/usr/local/lib/libtbb.dylib
に変更。これでどうにかなります。
と言いたいのですが、念のため、OpenCVを再インストール。

$ brew uninstall opencv
$ brew install opencv

これでOK。

[参考]
opencv - ld: library not found for -llibtbb.dylib - Stack Overflow

8
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
6