Ask Your Question
0

compiling a project based on OpenCV in ubuntu

asked 2011-11-25 09:11:18 -0500

Belal gravatar image

I have an error when doing cmake [actually rosmake] to my project, I have already installed OpenCV but I have this error:

Linking CXX shared library ../lib/libCornerHelper.so
  /usr/bin/ld: cannot find -lopencv_contrib
  /usr/bin/ld: cannot find -lopencv_legacy
  /usr/bin/ld: cannot find -lopencv_stitching
  /usr/bin/ld: cannot find -lopencv_gpu
  /usr/bin/ld: cannot find -lopencv_objdetect
  /usr/bin/ld: cannot find -lopencv_calib3d
  /usr/bin/ld: cannot find -lopencv_features2d
  /usr/bin/ld: cannot find -lopencv_video
  /usr/bin/ld: cannot find -lopencv_highgui
  /usr/bin/ld: cannot find -lopencv_ml
  /usr/bin/ld: cannot find -lopencv_imgproc
  /usr/bin/ld: cannot find -lopencv_flann
  /usr/bin/ld: cannot find -lopencv_core
  collect2: ld returned 1 exit status
  make[3]: *** [../lib/libCornerHelper.so] Error 1

How to solve it?

edit retag flag offensive close merge delete

Comments

The linker cannot find the specified libraries in the linker paths. For more specifics: Your CMake file, manifest.xml, ubuntu and ROS version will help.
dornhege gravatar image dornhege  ( 2011-11-25 09:23:58 -0500 )edit
Also the actual command being executed, i.e. export VERBOSE=1
jbohren gravatar image jbohren  ( 2011-11-25 15:59:25 -0500 )edit
thanks a lot, it works
Belal gravatar image Belal  ( 2011-11-26 00:14:11 -0500 )edit

I got the same problem. How did you solve it?

Astronaut gravatar image Astronaut  ( 2016-05-15 01:44:03 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-01-19 23:15:13 -0500

Claudio gravatar image

I suggest you do the following in a shell

$ pkg-config --libs --cflags opencv

Then accurately check the results of the command. If there still are missing libraries (as I think it is the case) then run

$ sudo updatedb
$ locate opencv_core (or any other missing lib)

This ought to tell you where the libraries are. Supposedly though nor the linker and neither pkg-config can find them, so probably they ended up installed in a place that is not on the pkg paths.

To check against this eventuality run

$ echo $LD_LIBRARY_PATH

This variable should contain the path to the OpenCV libs, if it is not so you have to add it OR move the libs in /usr/lib as they ought to be.

To proceed with the second solution you just have to do something like

$ sudo cp /root/user/path-to-OpenCV /usr/local/lib

For the first solution you have to edit the bash configuration file for your user

$ nano ~/.bashrc

A text editor will open, scroll to the last line. If you already have a line like

export LD_LIBRARY_PATH=something

than add the path to OpenCV to this line, otherwise create one like so

export LD_LIBRARY_PATH+=:/path/to/OpenCV

Close the shell window, reopen one (ALT+T shortcut) and retry the pkg-config, it should now be able to find your libraries.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-11-25 09:11:18 -0500

Seen: 5,610 times

Last updated: Jan 19 '13