Basic Build Issue Regarding Libs, Pkg-Config and Opencv

Basic build issue regarding libs, pkg-config and opencv

If pkg-config --libs opencv is outputting that, then you have a problem. Maybe a previous installation of OpenCV broke it, or maybe you are not using a version recent enough, or maybe it wasn't compiled successfully, or maybe there's a problem with the newest version from the repository.

Anyway, I'm using OpenCV 2.3.1 on Mac OS X and pkg-config --libs opencv outputs the following info:

-L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann 

You can try to compile your application by hand to see if anything else is broken:

g++ test.cpp -o test -I/usr/local/include/opencv -I/usr/local/include  -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann

Note that your install might have placed OpenCV headers and libraries in different directories.

Why does pkg-config --libs opencv return library locations and not the libraries themselves?

The output of the pkg-config is correct.

The GNU linker (ld) (I don't know if others too) allows you to write the libraries with their full path, without any -L or -l, in addition to the usual -L and -l options.

The error must be in some other place.

Package opencv was not found in the pkg-config search path

it seems that the ubuntu community has completed the documentation on installing openCV,

so all you have to do now is to download the installation script from here and execute it.

don't forget to make it executable:

chmod +x opencv_latest.sh

then

./opencv_latest.sh

OpenCV on beaglebone. pkg-config issues

you should be using backticks (`) instead of ' to substitute the output of pkg-config into the command line.

Compiling opencv program cause gcc -I/usr/local/lib test.cpp test.cpp:1:10: fatal error: opencv2/core.hpp: No such file or directory

With the -L option you should specify the library search path.

Then with -l options you specify the library names you'd like to link against.

So in your case I'd expect to see -L/usr/local/lib -lopencv_core. Note that the -l name has the lib prefix and file extension omitted. (You may need more OpenCV libraries.)

Seeing your struggles, I think it would be good to read a general tutorial about compiling and linking C/C++ programs (on your platform).

pkg-config --cflags opencv: No such file or directory

You used incorrect quotes. You should use ` instead of ':

CC=g++
CFLAGS=-O2 -g `pkg-config --cflags opencv`
LDFLAGS=`pkg-config --libs opencv`


Related Topics



Leave a reply



Submit