huihut / OpenCV-MinGW-Build

👀 MinGW 32bit and 64bit version of OpenCV compiled on Windows. Including OpenCV 3.3.1, 3.4.1, 3.4.1-x64, 3.4.5, 3.4.6, 3.4.7, 3.4.8-x64, 3.4.9, 4.0.0-alpha-x64, 4.0.0-rc-x64, 4.0.1-x64, 4.1.0, 4.1.0-x64, 4.1.1-x64, 4.5.0-with-contrib, 4.5.2-x64
https://opencv.org/
928 stars 215 forks source link

Error: undefined reference to `cv::VideoCapture::VideoCapture(std::string const&, int)' #30

Closed DuyDang007 closed 1 year ago

DuyDang007 commented 1 year ago

Hi,

I'm trying to compile my simple program to capture video frame, using msys mingw64. Currently I get this error:

# make
x86_64-pc-msys-g++ -I../opencv4.5.5/include -Iinclude -L../opencv4.5.5/x64/mingw/bin -lopencv_videoio_ffmpeg455_64 -lopencv_video455 -lopencv_videoio455 -lopencv_imgproc455 -lopencv_highgui455 -lopencv_imgcodecs455 -lopencv_core455 -g -O0 -o sample  main.cpp
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccfOqfBU.o:/e/dense_flow/structure_from_video/main.cpp:138: undefined reference to `cv::VideoCapture::VideoCapture(std::string const&, int)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:9: sample] Error 1

Tried with OpenCV 4.5.5, 4.1.0, 3.8.4. Nothing worked.

DuyDang007 commented 1 year ago

I figured out it was because I used msys g++ to link with mingw32 OpenCV lib