找到你要的答案

Q:ld: library not found for -llibtbb.dylib

Q:LD:没有找到-llibtbb.dylib图书馆

I try to compile some files from the opencv-2.4.8/apps/haarfinder but i get the following error:

ld: library not found for -llibtbb.dylib

Notice the double l in the filename.

I try to follow the tutorial here: http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html

And in the comments i readed:

After many, many hours of pondering and looking around. I decided to take it as a spelling error in some file so I decided to look into opencv files and search for that "-llibtbb" and finally found it. I corrected it to only "libtbb" and its finally working.

Sadly he didn't mention what file that was. I tried with sublime 'Find in files' but i can't find it.

Can someone else take a look or help me in another way? Like if i know where libtbb.dylib is stored i might be able to duplicate it and add the spelling error myself.

please help, i'm lost :)

我试着从opencv-2.4.8/apps/haarfinder编译一些文件,但我收到以下错误:

LD:没有找到-llibtbb.dylib图书馆

注意文件名中的双L。

I try to follow the tutorial here: http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html

在我读过的评论:

After many, many hours of pondering and looking around. I decided to take it as a spelling error in some file so I decided to look into opencv files and search for that "-llibtbb" and finally found it. I corrected it to only "libtbb" and its finally working.

Sadly he didn't mention what file that was. I tried with sublime 'Find in files' but i can't find it.

Can someone else take a look or help me in another way? Like if i know where libtbb.dylib is stored i might be able to duplicate it and add the spelling error myself.

请帮忙,我迷路了:

answer1: 回答1:

Suppose libtbb.dylib is in /usr/local/lib/libtbb.dylib and opencv.pc is in /usr/local/lib/pkgconfig (The location may vary depending on where you install tbb and pkg-config)

Then edit /usr/local/lib/pkgconfig/opencv.pc, change -llibtbb.dylib to /usr/local/lib/libtbb.dylib

假设libtbb.dylib在/ usr /局部/ lib / libtbb.dylib和opencv.pc在/ usr /局部/ lib / pkgconfig(位置可能取决于你安装TBB和pkg-config有所不同)

然后编辑/ usr /局部/ lib / pkgconfig / opencv.pc,改变-llibtbb.dylib到/usr/local lib / libtbb.dylib

answer2: 回答2:

Old question, but I needed it, or rather I found this better solution - and this may help other searchers.

Follow the instructions in the github description, rather than that blog post: https://github.com/mrnugget/opencv-haar-classifier-training

This corrects the spelling error in the command line:

g++ `pkg-config --libs --cflags opencv | sed 's/libtbb\.dylib/tbb/'`\
  -I. -o mergevec mergevec.cpp\
  cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp\
  cvhaartraining.cpp\
  -lopencv_core -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect

古老的问题,但我需要它,或者说我发现这更好的解决办法,这可以帮助其他人。

在GitHub的描述说明,而不是https://github.com/mrnugget/opencv-haar-classifier-training博客:

这将纠正命令行中的拼写错误:

g++ `pkg-config --libs --cflags opencv | sed 's/libtbb\.dylib/tbb/'`\
  -I. -o mergevec mergevec.cpp\
  cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp\
  cvhaartraining.cpp\
  -lopencv_core -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect
answer3: 回答3:

I installed opencv 2.4.12 with tbb from homebrew on El Capitan, and then separately downloaded the source from github in order to compile mergevec and the s/libtbb\.dylib/tbb/ fix on its own still didn't help.

My fix was to add -L/usr/local/lib to the start of the g++ arguments as by default it wasn't searching for my homebrew libs. I also had to add cvsamplesoutput.cpp as mentioned in another answer to fix the following error:

Undefined symbols for architecture x86_64:
  "IOutput::createOutput(char const*, IOutput::OutputType)", referenced from:
      JpgDatasetGenerator::JpgDatasetGenerator(char const*) in cvhaartraining-8f5a1b.o
      PngDatasetGenerator::PngDatasetGenerator(char const*) in cvhaartraining-8f5a1b.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The final command that worked for me was:

g++ -L/usr/local/lib `pkg-config --libs --cflags opencv | sed 's/libtbb\.dylib/tbb/'`\
  -I. -o mergevec mergevec.cpp  cvboost.cpp cvcommon.cpp cvsamples.cpp\
  cvhaarclassifier.cpp cvhaartraining.cpp cvsamplesoutput.cpp -lopencv_core\
  -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect

我安装opencv 2.4.12与TBB在El Capitan的自制软件,然后分别从GitHub下载源为了编写mergevec和S / libtbb \ .dylib / TBB /确定自己还没有帮助。

我的修改是增加L /usr/local/库开始的G +参数,默认情况下它不寻找我的自制程序库。我还添加cvsamplesoutput.cpp作为另一个答案提到修复以下错误:

Undefined symbols for architecture x86_64:
  "IOutput::createOutput(char const*, IOutput::OutputType)", referenced from:
      JpgDatasetGenerator::JpgDatasetGenerator(char const*) in cvhaartraining-8f5a1b.o
      PngDatasetGenerator::PngDatasetGenerator(char const*) in cvhaartraining-8f5a1b.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

为我工作的最后命令是:

g++ -L/usr/local/lib `pkg-config --libs --cflags opencv | sed 's/libtbb\.dylib/tbb/'`\
  -I. -o mergevec mergevec.cpp  cvboost.cpp cvcommon.cpp cvsamples.cpp\
  cvhaarclassifier.cpp cvhaartraining.cpp cvsamplesoutput.cpp -lopencv_core\
  -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect
answer4: 回答4:

IOutput is an interface where their methods are declared at ioutput.h and must be implemented somewhere. I found out they were implemented at cvsamplesoutput.cpp so we just need ask gcc to compile that file. For that the correct command should be:

g++ `pkg-config --libs --cflags opencv | sed 's/libtbb\.dylib/tbb/' ` -I. -o mergevec mergevec.cpp cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp cvhaartraining.cpp cvsamplesoutput.cpp -lopencv_core -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect

ioutput是一个接口,他们的方法是宣布在ioutput H必须执行的地方。我发现他们实施cvsamplesoutput.cpp所以我们只需要问GCC来编译这个文件。因为正确的命令应该是:

g++ `pkg-config --libs --cflags opencv | sed 's/libtbb\.dylib/tbb/' ` -I. -o mergevec mergevec.cpp cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp cvhaartraining.cpp cvsamplesoutput.cpp -lopencv_core -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect
answer5: 回答5:

If the libtbb.dylib file already exists like in my case in the /usr/local/lib folder then all you need to do is to run this command: export DYLD_LIBRARY_PATH=/usr/local/lib

If the libtbb.dylib file already exists like in my case in the /usr/local/lib folder then all you need to do is to run this command: export DYLD_LIBRARY_PATH=/usr/local/lib

opencv