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
Is There Some Cases in Which Sigkill Will Not Work
Linux + Ssh Limitation + Ssh at The Same Time from Multiple Machine to One Machine
Why Questionmark Comes in The End of Filename When I Create .Txt File Through Shell Script
Watchman Makes Fsnotify Spuriously Detect File Changes
Format and Filter File to CSV Table
Shell Must Parse Ls -Al Output and Get Last Field (File or Directory Name) Any Solution
Bypass Dev/Urandom|Random for Testing
Awk: Sum Up Column Values Across Multiple Files with Identical Column Layout
How to Save State When Preempted on a Google Preemptible Instance
How to Find Grid Points Nearest to Given Location Using Shell Script
Git Is Not Ignoring File Permission Changes
Difference Between Double and Single Bigger Than in Linux Terminal
How to Get Exact List of Collections Form Mongo Database in Shell Script
What's The Relation Between 32/64-Bit Application, Os and Processor