0

I have a container where opencv is installed. (click here if you want to see the dockerfile)

However once I enter the container when I do

pkg-config --cflags --libs opencv

I get

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

What could be happening and how can I solve this?

Notes: As you can see in the dockerfile, pkg-config seems to be installed also, I wanted to try the solution in here but under /usr/local/lib there is no folder or file called pkg-config

Also I made find / -name opencv.pc but got nothing.

Edit:

The cmake was called as

cmake \
        -DOPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib-${OPENCV_VERSION}/modules \
        -DWITH_CUDA=ON \
        -DCUDA_ARCH_BIN=7.5,8.0,8.6 \
        -DCMAKE_BUILD_TYPE=RELEASE \
        # Install path will be /usr/local/lib (lib is implicit)
        -DCMAKE_INSTALL_PREFIX=/usr/local \
        .. &&\

Edit2: The installation starts with

Install the project...
-- Install configuration: "RELEASE"
-- Installing: /usr/local/share/licenses/opencv4/ippicv-readme.htm
-- Installing: /usr/local/share/licenses/opencv4/ippicv-EULA.txt
-- Installing: /usr/local/share/licenses/opencv4/ippicv-third-party-programs.txt                         -- Installing: /usr/local/share/licenses/opencv4/ippiw-support.txt
-- Installing: /usr/local/share/licenses/opencv4/ippiw-third-party-programs.txt
-- Installing: /usr/local/share/licenses/opencv4/ippiw-EULA.txt
-- Installing: /usr/local/share/licenses/opencv4/opencl-headers-LICENSE.txt
-- Installing: /usr/local/include/opencv4/opencv2/cvconfig.h
-- Installing: /usr/local/include/opencv4/opencv2/opencv_modules.hpp
-- Installing: /usr/local/lib/pkgconfig/opencv4.pc

but inside the container /usr/local I dont see opencv

Final edit:

Could not figure out how to do this, but instead wrote a CMakeLists.txt file and used cmake and could build the sample

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
  • 1
    did you install with OPENCV_GENERATE_PKGCONFIG flag ON ? can you share cmakecommand u used ? – Yunus Temurlenk Aug 18 '23 at 17:53
  • By default, pkg-config checks several "standard" locations for the libs definitions. Your opencv is installed somewhere else or its pc file is missing. Put its location to PKG_CONFIG_PATH and you will get it working. – Cynichniy Bandera Aug 18 '23 at 18:25
  • @YunusTemurlenk No it was not installed with that. The repo did not ask for that and my textbook did not have that option either. (see edit) – KansaiRobot Aug 18 '23 at 19:29
  • you need to install it with that flag on to be able to use pkgconfig capabilities – Yunus Temurlenk Aug 18 '23 at 19:44
  • I rebuild it and installed it with that, the problem still persists – KansaiRobot Aug 18 '23 at 21:35
  • @CynichniyBandera not really sure but it seems it might be installed in `/usr/local/bin/`. There are some opencv related binary files there. The ouptut of the installation is like edit2 – KansaiRobot Aug 18 '23 at 21:38
  • As the command, it is intalled in `/usr/local` – KansaiRobot Aug 18 '23 at 21:56
  • 1
    I solved this by not using pkg-config anymore. Instead I build the program with cmake and it worked. Now the problem is that the program crashes but that is another problem. – KansaiRobot Aug 18 '23 at 22:22

0 Answers0