2

I am trying to use opencv with C++ in my jetson nano and I cannot build my C++ program (I remember vaguely that I could in the past)

The thing is if I try to compile the C++ code and it says

 fatal error: opencv2/opencv.hpp: No such file or directory  #include
<opencv2/opencv.hpp>

so I do

pkg-config --modversion opencv
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

and I do

pkg-config opencv --cflags
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

However if I do this:

python
Python 2.7.17 (default, Nov  7 2019, 10:07:09) 
[GCC 7.4.0] on linux2

and then

>>> import cv2
>>> cv2.__version__
'4.1.1'

I also have a python program using opencv and it works.

So what am I doing wrong with C++??

EDIT:

I managed to build my program following the directions of the OpenCV docs. (and similar to what I later found here

So I basically made a subdirectory where I put a CMakeLists.txt as in

cmake_minimum_required(VERSION 2.8)
project( first )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( first first.cpp )
target_link_libraries( first ${OpenCV_LIBS} )

and then run cmake . and then make

With that I could build the program.

But I have no idea why I could not build it with gcc and where the openCV is installed.

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150

0 Answers0