I get the Error "error: undefined reference to `cv::VideoCapture::VideoCapture(int, int)'"

Hi,
i’m using QT Creator as an IDE. My problem is, as stated in the topic name, that i’m getting a error that i have undefinded references as long its in the opencv-lib. The lib is installed under /usr/include/opencv4/opencv2/… and can be found by the IDE, but i’m getting these errors after i compiled the programm.

[ 50%] Linking CXX executable Trx2

CMakeFiles/Trx2.dir/main.cpp.o: In function `main’:

main.cpp:(.text+0x34): undefined reference to `cv::VideoCapture::VideoCapture(int, int)’

main.cpp:(.text+0x40): undefined reference to `cv::VideoCapture::~VideoCapture()’

collect2: error: ld returned 1 exit status

make[2]: *** [Trx2] Error 1

make[1]: *** [CMakeFiles/Trx2.dir/all] Error 2

make: *** [all] Error 2

CMakeFiles/Trx2.dir/build.make:94: recipe for target ‘Trx2’ failed

CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/Trx2.dir/all’ failed

Makefile:83: recipe for target ‘all’ failed

15:05:54: The process “/usr/bin/cmake” exited with code 2.

Error while building/deploying project Trx2 (kit: Desktop)

When executing step “CMake Build”

15:05:54: Elapsed time: 00:01.

I’m using opencv version 4.10.0-dev and Jetpack 4.6.5 [L4T 32.7.5].
I had tried everything that i came up with. I reinstalled opencv, used different tutorials for the installation, used building scripts such as the ones from jetsonHacks and Q-engineering (with CUDA and QT support). I also loaded the jetpack on my SD-Card again.

i want to use opencv with CUDA, Cudnn and QT Creator as an IDE to build a robot with a team. Normal Libs function just fine
we are thankfull for every little help ;)

Thats the simplest Program i came up with:
//include “opencv4/opencv2/opencv.hpp”

include “opencv4/opencv2/highgui.hpp”

include <opencv4/opencv2/core.hpp>

include <opencv4/opencv2/videoio.hpp>

include

include <stdio.h>

using namespace cv;

using namespace std;

int main(int argc, char const *argv)

{

//Open the default video camera

cv::VideoCapture cap(0);

return 0;

}

Hi,
We would suggest use older version of OpenCV. 4.10.0 is new version and may not be compatible with Jetpack 4 release.

And you may try the script to manually build OpeCV package:

GitHub - mdegans/nano_build_opencv: Build OpenCV on Nvidia Jetson Nano

Hi, thank you for your respond
i built opencv 4.4.0 and it the build was completed without any errors, but i’m facing the same error and when i’m trying to run the script via commands in terminal then I’m also facing the same issue

Or are my gcc and g++ versions wrong?
gcc (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0
g++ (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0