Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.0.0 does not produce pkgconfig file #13154

Closed
ekudritski opened this issue Nov 13, 2018 · 41 comments
Closed

4.0.0 does not produce pkgconfig file #13154

ekudritski opened this issue Nov 13, 2018 · 41 comments
Labels
category: build/install question (invalid tracker) ask questions and other "no action" items here: https://forum.opencv.org wontfix

Comments

@ekudritski
Copy link

System information (version)
  • OpenCV => 4.0.0-rc
  • Operating System / Platform => Ubuntu 18.10
  • Compiler => gcc 8.2.0 / gcc 6
Detailed description

I did cmake ...Then make and then make install
and it does not generate opencv.pc file.

If I use same commands for version 3.4.3 then the file is created.

Another thing
if I link with pkgconfig then it links to librarys with no version numbers.
so installing 4.0.0-rc after 3.4.3 makes pkgconfig unusable.
it would be nice if there were multiple opencv.pc files like opencv3.4.pc opencv4.pc

@alalek
Copy link
Member

alalek commented Nov 13, 2018

Pkg-config has very limited functionality, so this support has been dropped.

Use CMake with find_package(OpenCV) instead (with multiple version selection, "on the fly" configuration via script language, etc).

Changes are here:


In general, package maintainers should provide own .pc file validated for provided OpenCV build configuration. Perhaps written from the scratch.

@dustsigns
Copy link

Is there a way to reintroduce pkg-config support? The .pc files that are currently generated seem to work for most settings and not everyone is using cmake. It seems to me that just having a list of libraries that OpenCV depends on as well as the information where the header and .so files are is already sufficient for most use cases with pkg-config. Or is there any limitation in this regard?

@ekudritski
Copy link
Author

Option OPENCV_GENERATE_PKGCONFIG=ON generates the '.pc' file. I think also it should be generated by default in *nix systems where pkg-config is used. I tested my binary files with ldd and they are linked right. It is just development time when conflicts can occur. And I think same problems can occur with cmake also. It is possible to be more specific than just -llib. its possible to specify libs exactly by .so file.

@codenoid
Copy link

codenoid commented Dec 21, 2018

CMakeLists.txt :

OCV_OPTION(OPENCV_GENERATE_PKGCONFIG  "Generate .pc file for pkg-config build tool (deprecated)" ON)

it doesn't work

@pathouse
Copy link

@codenoid i believe the argument for that option is actually YES

@rdp
Copy link

rdp commented Jan 11, 2019

ffmpeg relies on .pc files for opencv library dependency, FWIW...

@rdp
Copy link

rdp commented Jan 13, 2019

Also as a note "make install" doesn't install the .pc file, even if it's generated :|

@Favi0
Copy link

Favi0 commented Jan 15, 2019

Also as a note "make install" doesn't install the .pc file, even if it's generated :|

have you managed to install the .pc file?

@rdp
Copy link

rdp commented Jan 16, 2019 via email

@tsengia
Copy link
Contributor

tsengia commented Jan 23, 2019

I had the same issue, thankfully I found this thread, and I must agree, not everyone uses cmake.
For anyone that stumbles upon this thread with the same issue, I used
cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=YES -D CMAKE_INSTALL_PREFIX=/usr/local ..

The key here being: -D OPENCV_GENERATE_PKGCONFIG=YES
Then continue build and install as normal. I've checked and it does seem that OpenCV does install the .pc file now, so no need to manually copy it over. The package will be installed named as "opencv4", so use pkg-config --cflags opencv4.

@Adhders
Copy link

Adhders commented Mar 7, 2019

System information (version)
  • OpenCV => 4.0.0-rc
  • Operating System / Platform => Ubuntu 18.10
  • Compiler => gcc 8.2.0 / gcc 6
Detailed description

I did cmake ...Then make and then make install
and it does not generate opencv.pc file.

If I use same commands for version 3.4.3 then the file is created.

Another thing
if I link with pkgconfig then it links to librarys with no version numbers.
so installing 4.0.0-rc after 3.4.3 makes pkgconfig unusable.
it would be nice if there were multiple opencv.pc files like opencv3.4.pc opencv4.pc

opencv 4.0.1 has his question too, after making install , there is no opencv.pc generated, even no pkgconfig file

@jhgfkdj
Copy link

jhgfkdj commented Apr 4, 2019

I had the same issue, thankfully I found this thread, and I must agree, not everyone uses cmake.
For anyone that stumbles upon this thread with the same issue, I used
cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=YES -D CMAKE_INSTALL_PREFIX=/usr/local ..

The key here being: -D OPENCV_GENERATE_PKGCONFIG=YES
Then continue build and install as normal. I've checked and it does seem that OpenCV does install the .pc file now, so no need to manually copy it over. The package will be installed named as "opencv4", so use pkg-config --cflags opencv4.

I did it as you told but there was still no pkgconfig nor opencv.pc ...

@UberEclectic
Copy link

I added the "-D OPENCV_GENERATE_PKGCONFIG=YES" flag, ran cmake, make, and found:

.../unix-install/opencv4.pc

As mentioned by others, "make install" didn't copy the file anywhere under /usr/local.
I can't glean where opencv4.pc should go by merely reading the pkg-config man page -- some place under /usr/local, but exactly where?

@Kevin-Mok
Copy link

Also had the same problem where make install didn't copy over opencv4.pc, but I was using the 4.1.0 zip from the release page.

@corbelr
Copy link

corbelr commented Apr 25, 2019

@UberEclectic @Kevin-Mok The opencv4.pc file should be copied to /usr/local/lib/pkgconfig. Don't forget to 'sudo ldconfig', for making sure the recently installed OpenCV libraries are correctly taken into account. RC

@un-lock-me
Copy link

I had the same issue, thankfully I found this thread, and I must agree, not everyone uses cmake.
For anyone that stumbles upon this thread with the same issue, I used
cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=YES -D CMAKE_INSTALL_PREFIX=/usr/local ..

The key here being: -D OPENCV_GENERATE_PKGCONFIG=YES
Then continue build and install as normal. I've checked and it does seem that OpenCV does install the .pc file now, so no need to manually copy it over. The package will be installed named as "opencv4", so use pkg-config --cflags opencv4.

It did not install .cp file in my case.

@un-lock-me
Copy link

un-lock-me commented Apr 29, 2019

Yeah I just manually copied it in. :|

On Tue, Jan 15, 2019 at 2:20 PM Favi0 @.***> wrote: Also as a note "make install" doesn't install the .pc file, even if it's generated :| have you managed to install the .pc file? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#13154 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAw0IVOZFkcmQtjPGnwDjxWhzJoO-dxks5vDkYegaJpZM4Ycby9 .

How did you do that?, In my case it even have not created opencv.cp file!

@rdp
Copy link

rdp commented Apr 30, 2019 via email

@sergiomb2
Copy link
Contributor

useful if not using CMake in projects that use OpenCV

don't say that is deprecated [1] please

[1]
73f65b1

@prabindh
Copy link

On 4.1.0, and the below does not generate pc file
cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=YES -D CMAKE_INSTALL_PREFIX=/usr/local ..

@prabindh
Copy link

With 4.1.0, got it functional. I found the mistake in the command provided earlier. Need to use ON, instead of YES.

OPENCV_GENERATE_PKGCONFIG=ON

pkg-config --cflags opencv4
-I/usr/include/opencv4/opencv -I/usr/include/opencv4
$ pkg-config --libs opencv4
-lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_gapi -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_stitching -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core

@sergiomb2
Copy link
Contributor

useful if not using CMake in projects that use OpenCV

don't say that is deprecated [1] please

[1]
73f65b1

I change my point of view maybe can be called deprecated ...

@ytm95
Copy link

ytm95 commented Jun 12, 2019

So the -D OPENCV_GENERATE_PKGCONFIG=ON option in cmake is deprecated now? How can we get the pkgconfig and opencv.pc files then?

@sergiomb2
Copy link
Contributor

So the -D OPENCV_GENERATE_PKGCONFIG=ON option in cmake is deprecated now? How can we get the pkgconfig and opencv.pc files then?

if you not explicitly add OPENCV_GENERATE_PKGCONFIG=ON is not generated .

I added to my %cmake

-DOPENCV_GENERATE_PKGCONFIG=ON \
-DOPENCV_PC_FILE_NAME=opencv.pc \

For cmake files be installed in default cmake folder I add :

-DOPENCV_CONFIG_INSTALL_PATH=%{_libdir}/cmake/OpenCV \

@mkschreder
Copy link

Please don't force everyone to use CMAKE. Many projects don't use CMAKE and for good reasons.

@kwizart
Copy link

kwizart commented Mar 25, 2020

Hi there.

I don't like putting -1 on already accepted (but biased) proposal, but here a wider explanation:

it would be nice if there were multiple opencv.pc files like opencv3.4.pc opencv4.pc

If one application is compatible with opencv2 -> opencv5 (if ever future master is 5 ), then it's easy enough to rely on the same opencv.pc (when using pkgconf), and not to adapt every now and then.

My point to keep using opencv.pc by default is to avoid having to adapt applications everytime the opencv.pc version changes. Because from a distro package maintainer, it's easier if everyone use the same opencv.pc.
You can see the #16902 for other comments on the topic.

@Usernamezhx
Copy link

Usernamezhx commented May 14, 2020

I try OPENCV_GENERATE_PKGCONFIG=ON. but not work.
I try OPENCV_GENERATE_PKGCONFIG=YES. but not work.
I try -DOPENCV_GENERATE_PKGCONFIG=ON. but not work.
opencv 4.3.0
I install opencv to my local path. such as /data/home/xxx/opencv. I use make and make install. or make make install. both not work.
I give up. I will add lib and include file to makefile.

@thewoz
Copy link
Contributor

thewoz commented May 15, 2020

in the cmake option you need to put -DOPENCV_GENERATE_PKGCONFIG=ON
then after have performed the make "command" you will find in your build folder a folder with the name of you os (I my case "unix") with inside the .pc file

@tordals
Copy link

tordals commented May 15, 2020

@Usernamezhx

You didn't forget the "-D" option, did you?

I have always had a space after -D as in the docs, like:
-D OPENCV_GENERATE_PKGCONFIG=ON

but writing without the space apparently works as well:
-DOPENCV_GENERATE_PKGCONFIG=ON

The following below is a quote from my install script and the cmake part definitively works for opencv 4.2.0. This quote is not a complete install script by any means. I have lots of libraries installed separately before that so you need to make a script of your own for your own purposes. Do not forget the ldconfig at the end as that finalizes some install stuff on Linux. You may also need to edit you paths in ~/.bashrc. First moving downloaded stuff to opencv folder then etc...

mv opencv-4.2.0 opencv
cd opencv
mkdir build
cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_QT=ON -D OPENCV_GENERATE_PKGCONFIG=ON -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_V4L=ON -D WITH_EIGEN=ON -D WITH_OPENGL=ON -D FORCE_VTK=ON -D WITH_TBB=ON -D WITH_XINE=ON -D BUILD_EXAMPLES=ON -D BUILD_PERF_TESTS=OFF -D ENABLE_PRECOMPILED_HEADERS=OFF .. -D INSTALL_C_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D BUILD_opencv_python3=ON -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-4.2.0/modules ..

make -j6
sudo make install
sudo ldconfig

Check where your opencv4.pc is:

First move all the way up, twice from your home with
cd ..
cd ..

Then:

sudo find -name opencv4.pc

You should find some pkgfolders with this:

sudo find -name pkgconfig

Hope this helps.

@tordals
Copy link

tordals commented May 15, 2020

PS. The copy of cmake in my previous post must be a one single continuous line without line breaks. Just add proper line breaks if you want to split it manually to multiple lines.
Once you think you have opencv properly installed you can test it, first move to the cpp samples folder like:

cd ~/opencv/samples/cpp

Compile the opencv_version.cpp to a run file named show_my_version

g++ opencv_version.cpp $(pkg-config --cflags --libs opencv4) -o show_my_version

and run it : ./show_my_version

@Usernamezhx
Copy link

@dalilander yeah. it works. so amazing. thanks for your kindly reply.

@hardikparwana
Copy link

I faced a similar issue after installing OpenCV 4.2.0 and could not find a way to compile a c++ program using CMakeLists.txt. I had other versions of OpenCV installed too so had to provide specific path to compiler. The pkg--configs was set and could identify opencv4 thanks to the solution posted above for building OpenCV with -D OPENCV_GENERATE_PKGCONFIG=YES > Although had to export the pkg-config .pc file path to the environment variable like this:
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/ubuntu/opencv/opencv4/lib/pkgconfig

The usual way I compiled with OpenCV upto version 3.4.4 was cmake . -DOpenCV_DIR=~/opencv/opencv4/share/ (or /usr/local/share/OpenCV), however it didn't work with 4.2.0. Finally noticed that 4.2.0 didn't put the Config.cmake and Config-version.cmake files in the share/ directory. Instead they were put in a separate /lib/cmake/opencv4/ directory. Now I can compile all programs with cmake. -DOpenCV_DIR=(yopur opencv installation location)/opencv4/lib/cmake/opencv4 and everything works perfectly!

I also added find_package( OpenCV 4.2.0 REQUIRED ) in CMakeLists.txt. Not sure if this is the best way but hope it helps others!

@iuri
Copy link

iuri commented Aug 14, 2020

Hello there,
I tried the suggestions above (thanks to @dalilander and @hardikparwana), but none of them worked. the installation is: Raspberry PI 4 ARMv7l, Centos 7.
OpenCV is the latest available in GitHub repository, v.4.4 https://github.com/opencv/opencv/

I compiled openCV as in the command bellow. I also tried ... =ON as in ... -D OPENCV_GENERATE_PKGCONFIG=YES

make3 -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_GENERATE_PKGCONFIG=YES -D OPENCV_EXTRA_MODULES_PATH=/usr/local/src/opencv_build/opencv_contrib/modules -D BUILD_EXAMPLES=ON ..

Then, I followed the installation steps,

make -j4 (in my case is 4)
sudo make install
sudo ln -s /usr/local/lib64/pkgconfig/opencv4.pc /usr/share/pkgconfig/
sudo ldconfig
pkg-config --modversion opencv4

then, it returns the error bellow

@Rasp build]$ pkg-config --modversion opencv4
Package opencv4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv4.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv4' found

Must I add opencv4.pc manually? How must I add it?

Best wishes,
I

@hardikparwana
Copy link

@iuri I think you did not export the PKG_CONFIG_PATH like I proposed in my solution. You need to do it manually. I think your problem will be solved once you do it.
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/ubuntu/opencv/opencv4/lib/pkgconfig

Just replace the path with yours.

@iuri
Copy link

iuri commented Aug 15, 2020

Exactly!
and why didn't I export it?
Because there is no such file called Config.cmake neither Config-version.cmake in the share/ or /lib directory. They don't even exist in the entire filesystem. By the way, I noticed your examples is for Ubuntu, my O.S. is Centos 7, Arch is armV7L
I ran "find" in the command line, and there was only samples within openCV directory.

[@Rasp ~]$ sudo find / -iname "Config.cmake"
/usr/local/src/opencv_build/opencv/samples/hal/c_hal/config.cmake
/usr/local/src/opencv_build/opencv/samples/hal/slow_hal/config.cmake
[@Rasp ~]$ sudo find / -iname "Config-version.cmake"
[@Rasp ~]$

Should I install pkg_config ?
https://stackoverflow.com/questions/28997618/installing-pkg-config-files-to-proper-path-on-centos-with-automake

Best wishes,
I

@qonteo
Copy link

qonteo commented Aug 16, 2020

Hi there,
I found the answer!
Actually, I found the problem. I noticed symlink was assigned to the wrong direction

sudo ln -s /usr/local/lib64/pkgconfig/opencv4.pc /usr/share/pkgconfig/

There is no /lib64/. So, I removed that symlink, searched for any reference of opencv.pc in the filesystem, found "usr/local/lib/pkgconfig/opencv.pc" , then created a new symlink,

ln -s /usr/local/lib/pkgconfig/opencv.pc /usr/share/pkgconfig/

"pkg-config --modversion opencv" now returns 3.4.11.

It seems I've got a previous version of openCV, which I had installed from YUM pkg manager system.

I'm going to clean up that version, and start from scratch a new openCV insllation from the 4.2 source.

Best wishes,
I

@typelogic
Copy link

Using well-known system paths such as /usr/lib/ or /usr/local/lib etc as destination dirs when compiling/installing anything from source smells fishy to me as its collision course is imminent with system updates. I have my destination dirs for anything I manually compile and install set to /opt/my/opencv/4.0.0/, for example. And leave the system stuff alone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: build/install question (invalid tracker) ask questions and other "no action" items here: https://forum.opencv.org wontfix
Projects
None yet
Development

No branches or pull requests