ld: library not found for -llibtbb.dylib

后端 未结 5 2342
忘掉有多难
忘掉有多难 2021-02-14 08:41

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

Notic

相关标签:
5条回答
  • 2021-02-14 09:27

    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
    
    0 讨论(0)
  • 2021-02-14 09:33

    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
    
    0 讨论(0)
  • 2021-02-14 09:35

    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
    
    0 讨论(0)
  • 2021-02-14 09:39

    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

    0 讨论(0)
  • 2021-02-14 09:47

    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

    0 讨论(0)
提交回复
热议问题