pkg-config can't find opencv - c++

I installed opencv on a lubuntu 12.10 distro. Then when I try to compile a code which is using opencv it says it can't find it. So I try in a terminal :
pkg-config --cflags --libs opencv
It answers me that it can't find opencv. But the files are installed in /usr/lib. I don't understand why it can't find them.

You have to put pkg-config --cflags --libs opencv at the end of your g++ line. For example :
g++ test.cpp -o test `pkg-config --cflags --libs opencv`
Compiles
g++ `pkg-config --cflags --libs opencv` test.cpp -o test
Doesn't compile and have undefined reference.

For OpenCV 4 you might have to use:
pkg-config --cflags --libs opencv4
(Note the 4 in the end!)

From OpenCV 4:
add -DOPENCV_GENERATE_PKGCONFIG=YES to cmake build arguments.
Use YES, ON is not working anymore.

Related

No package 'opencv' found

I'm trying out this github repository, one of the requirements is to have opencv 3.1
when I run pip list I have opencv-python and opencv-contrib-python both version 4.7.0.68
$ g++ -std=c++11 Heartbeat.cpp opencv.cpp RPPG.cpp `pkg-config --cflags --libs opencv` -o Heartbeat
but when I run the above I get the error below
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
Please use opencv4 instead of opencv. So your command will look like:
g++ -std=c++11 Heartbeat.cpp opencv.cpp RPPG.cpp `pkg-config --cflags --libs opencv4` -o Heartbeat
It should work.

Permantly provide path to the headers and linker flags in OpenCV Linux

I have OpenCV 4.5.1 installed in Linux. But each time I restart I have to separely provide path to the headers and linker flags. and then compile ?
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/parallels/opencv4.5-custom/lib/pkgconfig
pkg-config --cflags --libs opencv4
and then
g++ -Wall -std=c++11 -o main main.cpp $(pkg-config --cflags --libs opencv4)
I just want to run the g++ comand each time

unable to compiling c++ with openCV even using 'pkg-config --cflags --libs opencv` in Linux

good morning,
please I need help-
I have a file: s.cpp
that uses:
#include <opencv2/highgui.hpp>
#include <opencv2/features2d.hpp>
and I wrote a makefile like this:
s: s.o
g++ s.o -o s
s.o: s.cpp
g++ s.cpp -c `pkg-config --cflags --libs opencv`
clean: rm -f s
and got the error:
g++ s.cpp -c `pkg-config --cflags --libs opencv`
s.cpp:9:10: fatal error: opencv2/highgui.hpp: No such file or directory
#include <opencv2/highgui.hpp>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
please, I dont know what to do
please someone can help?
if you are are trying to link more libraries all together in one time using the pkg-config command, I solved my problems on code::blocks with the command
pkg-config --libs --cflags opencv4
written in the project->build option->"program name"->linker settings->other linker option

libxml++/libxml++.h: No such file or directory

I am using ubuntu 12.4 g++ i'm working on libxml++ library I have included this library in my program but I am getting an error saying
libxml++/libxml++.h: No such file or directory
i also tried compiling using g++ main.cc -o main pkg-config --cflags --libs libxml++-2.6 but it is not working. I have installed the latest libraries using sudo apt-get install libxml++.
While compiling for libxml we have to use these options. pkg-config --cflags --libs libxml++-2.6 this should be in single quotation mark / Backticks ("`", grave accents), .
So the command should be like this.
$ g++ main.cc -o program `pkg-config --cflags --libs libxml++-2.6`
or go through this once. http://developer.gnome.org/libxml++/stable/

Setting up OpenCV. g++ error missing argument to ā€˜-lā€™. Linking error

I'm trying to setup a trivial OpenCV example following instructions from here. But when I try to run my example using
$ g++ -ggdb `pkg-config --cflags opencv` -o `basename opencvtest.cpp .cpp` opencvtest.cpp `pkg-config --libs opencv`
$ ./opencvtest`
I get the following error
g++ error missing argument to ā€˜-lā€™
I would appreciate any insight on how I could solve this.