0

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?

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
Shirly
  • 38
  • 6
  • Compile your C++ code with [GCC](http://gcc.gnu.org/) invoked as `g++ -Wall -Wextra -g s.cpp -c $(shell pkg-config --cflags --libs opencv)` in your `Makefile`. Add `-H` flag to understand what files are included. On [Debian](https://debian.org/) you need development packages related to OpenCV like `libopencv-dev` – Basile Starynkevitch Feb 21 '21 at 09:06
  • I tried what you @BasileStarynkevitch suggested: `code` shape: shape.o g++ shape.o -o shape shape.o: shape.cpp g++ -Wall -Wextra -g shape.cpp -c $(shell pkg-config --cflags --libs opencv) and it didnt change anything – Shirly Feb 21 '21 at 09:23
  • 1
    Don't comment your own question. Please [edit](https://stackoverflow.com/posts/66299998/edit) it to improve it. – Basile Starynkevitch Feb 21 '21 at 09:35
  • 2
    Does this answer your question? [main.cpp:1:10: fatal error: opencv2/highgui.hpp: No such file or directory](https://stackoverflow.com/questions/54912640/main-cpp110-fatal-error-opencv2-highgui-hpp-no-such-file-or-directory) – brc-dd Feb 21 '21 at 09:41

1 Answers1

1

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

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
marco
  • 11
  • 1