Build error: Missing pkg-config, in Code::Blocks IDE on Raspberry Pi

  1. Open CV has been installed on my Raspberry Pi 4.

  2. A check confirms that the latest version of Libopencv-dev is installed (4.6.0+dfsg-12).

  3. I am using the Code::Blocks IDE to devlop in C++.

  4. It is configured the use the Default CMake build tool.

  5. When trying to link to OpenCV4 library files from Code::Blocks IDE, I get the following error:
    g++ -L/usr/include/opencv4/ -L/usr/include/opencv4/opencv2/ -o bin/Release/TestCamera obj/Release/SimpleGrab.o ‘pkg-config --libs --cflags opencv4’ ‘pkg -config - - libs - -cflags opencv4’ -s

  6. I think this error may imply it cannot find the ‘pkg-config’.
    I am clearly missing something as the Pi is relatively new to me. so any help would be really appreciated.

pkg-config is deprecated / disabled by default
(no files installed for this)

try either:

  • specify libs & includes explicitly on the cmdline (recommended !!)
  • build your local makefile using cmake
  • rebuild the opencv libs & enable the pkg mechanism

Dear berak,
That makes perfect sense and I agree with your option 1 approach. However, whilst I can find the include files in: /usr/include/opencv4
I cannot find the path to the library files (.lib, .dll?). Could you help with this too, please?
Many thanks,

imo you have to go back to 1) (how did you install it ??)
DID you really run a final make install? what was the CMAKE_INSTALL_PREFIX set to ?

default should have been: /usr/local/include/opencv4 and /usr/local/lib for the libs. (note: local !) also look for *.so or *.la files , not dll on your os.

So, this far I have followed a number of installation scripts I have found online, including those requiring a build, which have failed for various reasons
. Is there one for the Raspberry Pi which you would recommend and that will work for the later versions of Pi OS?
Thank you.