0

I have the following issue encoutering during caffe installation: /usr/bin/ld: cannot find -lopencv_imgcodecs

I built opencv3.2, but I believe I have an issue with linking the cv2.cpython-36m-x86_64-linux-gnu.so library. I tried adding it to the LD_LIBRARY_PATH but it still fails with the same error.

Shall I make a link to the cv2.cpython-36m-x86_64-linux-gnu.so in the LD path? if yes, which path exactly shall I make the link in it.

Here is the last few lines of the output (the error msg):

CXX examples/mnist/convert_mnist_data.cpp
CXX .build_release/src/caffe/proto/caffe.pb.cc
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: cannot find -lopencv_imgcodecs
collect2: error: ld returned 1 exit status
Makefile:572: recipe for target '.build_release/lib/libcaffe.so.1.0.0' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1
Kasparov92
  • 1,365
  • 4
  • 14
  • 39
  • Please check this http://stackoverflow.com/questions/37741072/unable-to-install-caffe/43088610 – Rupesh May 19 '17 at 11:00
  • I did find nothing of use in that solution, I also do not want to try `conda install -c menpo opencv3=3.2.0` as I already compiled and build by hand the opencv3.2 and willing to know which step I miss now. It am thinking it is a linking issue – Kasparov92 May 19 '17 at 11:11
  • 1
    It can't find the way to reach libopencv_imgcodecs.so, check where it is located & add same path in LIBRARY_DIRS of Makefile.config – Rupesh May 19 '17 at 11:19
  • I found that in `/home//anaconda3/envs//lib` and I believe you are right! it fixed the erorrs, now I better solve the other erros :D Thanks! Please add it as an answer – Kasparov92 May 19 '17 at 11:33

1 Answers1

1

It can't find the way to reach libopencv_imgcodecs.so, check where it is located & add same path in LIBRARY_DIRS of Makefile.config

Open your Makefile.config file, you'll find the following lines:

  # Whatever else you find you need goes here.
    INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
    LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

If you've found the location, for example /home/username/anaconda3/envs/env-name/lib, then add it to LIBRARY_DIRS.

LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /home/<username>/anaconda3/envs/<env-name>/lib
Rupesh
  • 1,636
  • 13
  • 18
  • I found the reason why it failed, in `PYTHON_LIB := $(ANACONDA_HOME)/lib` I changed `ANACONDA_HOME := $(HOME)/anaconda3/` to `ANACONDA_HOME := $(HOME)/anaconda3/envs//` and adjusting the PYTHON_INCLUDE path correspondly fixed my issue :) – Kasparov92 May 19 '17 at 11:45
  • If anyone came across this issue and cannot locate the library, please refer to http://stackoverflow.com/a/12335952/871418. Also you can look for it in other ways like ctrl + F in some suspected directories – Kasparov92 May 19 '17 at 12:09