0

I was using this guide to build OpenCV from the source.

https://linuxize.com/post/how-to-install-opencv-on-ubuntu-20-04/

Now I am using meson to build and compile my project. I am trying to use 2 different methods to include OpenCV in my project and both ways work.

Method 1:

cv2 = dependency('OpenCV', method: 'cmake')

Method 2:

cv2 = dependency('opencv4', required: true)

when I compile with meson I get:

Dependency opencv4 found: YES 4.6.0 (cached)
Has header "opencv4/opencv2/bgsegm.hpp" : YES (cached)
Has header "opencv4/opencv2/calib3d.hpp" : YES (cached)
Has header "opencv4/opencv2/core.hpp" : YES (cached)
Has header "opencv4/opencv2/imgproc.hpp" : YES (cached)
Has header "opencv4/opencv2/objdetect.hpp" : YES (cached)
Has header "opencv4/opencv2/opencv.hpp" : YES (cached)
Has header "opencv4/opencv2/video.hpp" : YES (cached)

which is great.

finally I am using:

lala = executable('lala','lala.cpp',
                    c_args : args,
                    include_directories : [includes_lala],
                    dependencies : [some_deps,cv2],
                    cpp_args : ['-g','-ggdb'],
                    link_with  : some_lib )

but I am getting the next following error:

In file included from ../src/lala.cpp:1:
../include/lala.hpp:16:10: fatal error: opencv2/opencv.hpp: No such file or directory
   16 | #include "opencv2/opencv.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.

I didn't find any solution. thanks!

3
  • Could you show result of $ pkg-config --cflags opencv4 ? Commented Dec 8, 2022 at 15:10
  • And try #include <opencv2/opencv.hpp> Commented Dec 8, 2022 at 15:11
  • 1
    <> or "" only affect lookup order, not success. -- figure out what "include directories" you're giving the compiler. the pkg-config result should contain that Commented Dec 8, 2022 at 18:11

1 Answer 1

0

Problem solved.

I missed one of the executable files that should include the OpenCV dependency too.

dependencies : [somestuff,cv2]

thanks for the help!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.