10

I have ubuntu 10 installed. I installed all the opencv packages I could find in the software center. I expect that it installs some .lib files somewhere that I can reference in my project, but I can't find them. Where does it put them?

I want to use eclipse as the ide programming in c++, but I am having problems finding out how to get it setup initially. I am new to programming in eclipse and ubuntu in general so if anyone has a step by step guide I would love to see it.

Billy ONeal
  • 104,103
  • 58
  • 317
  • 552
Mr Bell
  • 9,228
  • 18
  • 84
  • 134

4 Answers4

21

You can find the proper link flags using pkg-config --libs opencv and the proper includes using pkg-config --cflags opencv.

The actual libraries should be installed in /usr/lib and having names such as libhighgui.a or libhighgui.so, but you likely won't have to reference those directly. Just use the output of the above commands in the proper place in Eclipse for setting link flags and include directories. If you really do want to know which libs are OpenCV related, the output of pkg-config --libs opencv will give you the names. For example, one of the outputs of that command is -lhighgui, so we know there should be a file named libhighgui.so in /usr/lib.

I haven't used Eclipse in a while for C or C++, so I can't remember where those options are, but they are around somewhere.

Eric Perko
  • 1,026
  • 7
  • 14
  • ok, that explains why I couldnt find them. I was expecting to find actual .lib files ie a file like opencv.lib. Are lib*.so files in ubuntu the same thing as .lib files in windows? – Mr Bell Jul 07 '10 at 22:18
  • @Mr Bell: I'm not 100% what exactly a .lib file is on Windows, so can't really answer that. However, in Linux, a lib*.so corresponds to a shared library while a lib*.a corresponds to a static library. Hope that helps. – Eric Perko Jul 08 '10 at 14:23
  • Package opencv was not found in the pkg-config search path. Perhaps you should add the directory containing `opencv.pc' to the PKG_CONFIG_PATH environment variable No package 'opencv' found – waspinator Mar 18 '13 at 21:14
  • Hi, I used the official tutorial of opencv.org but can't complete installation. I did what is said [here](http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation) but when I try to add the path, I just can't find it. There's nothing in include folder of my ubuntu 14.04.1 Can you please help me? – Rasool Aug 24 '14 at 13:26
5

As stated by Eric

pkg-config --libs opencv

will return libs to be included and if it is about the include file paths

it is /usr/include/opencv and if you want it to be automatically added just add following to command along with the command by Eric --cflags to above command.

Eg. let the file to be compiled be test.c then whole command will be

g++ test.c `pkg-config --libs --cflags opencv`

hope it helps.

skjoshi
  • 2,493
  • 2
  • 27
  • 38
  • 1
    This is a sensible answer. To add to this, I would suggest using `g++` instead of `gcc`. This will automatically link against stdc++, in case a linking error is thrown at compilation time. – Rob Stewart Jul 22 '13 at 18:09
  • Hi, I used the official tutorial of opencv.org but can't complete installation. I did what is said [here](http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation) but when I try to add the path, I just can't find it. There's nothing in include folder of my ubuntu 14.04.1 Can you please help me? – Rasool Aug 24 '14 at 13:27
2

OpenCV libraries are installed as in .a(static library) or .so(dynamic library) format.

You can find OpenCV2 (i.e. C++ version) libraries (e.g. libopencv_core.so,libopencv_highgui.so etc) at /usr/local/lib. If you want libraries for c version only (e.g. libcv.a,libcxcore.a etc) you can find them at /usr/lib.

Partha Bera
  • 448
  • 1
  • 3
  • 9
2

dpkg -L opencv will give you a list of all files installed from the opencv package. Be warned, however, that it won't show files that aren't in the package itself but get generated when the package is installed. Not being familiar with opencv, I don't know whether this will be a problem for you.

Paul Kuliniewicz
  • 2,711
  • 18
  • 24