I am trying to build simple program in VSCode that uses OpenCV, read thousands of posts on stack already and they all are made on linux (and I try to do it on windows) here's my code
This is what i tried to use:
"args": [
"-g",
"-I",
"C:\\OpenCV\\opencv\\build\\include",
"${file}",
"-L",
"C:\\OpenCV\\opencv\\build\\x64\\vc15\\lib",
"-l",
"opencv_world345",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
I checked the paths few times
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv )
{
if ( argc != 2 )
{
printf("usage: DisplayImage.out <Image_Path>\n");
return -1;
}
Mat image;
image = imread( argv[1], 1 );
if ( !image.data )
{
printf("No image data \n");
return -1;
}
namedWindow("Display Image", WINDOW_AUTOSIZE );
imshow("Display Image", image);
waitKey(0);
return 0;
}
And this is the result i got
Executing task: C:\MinGW\bin\g++.exe -I C:\OpenCV\opencv\build\include >d:\programowanie\Projekt\Project\main.cpp -L >C:\OpenCV\opencv\build\x64\vc15\lib -l opencv_world345 -o >d:\programowanie\Projekt\Project\main.exe <
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: >C:\Users\xxx\AppData\Local\Temp\ccXtHNOY.o:main.cpp:(.text+0x72):undefined reference to
cv::imread(cv::String const&, int)' c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: >C:\Users\xxx\AppData\Local\Temp\ccXtHNOY.o:main.cpp:(.text+0xe3): undefined reference to
cv::namedWindow(cv::String const&, int)' c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: >C:\Users\xxx\AppData\Local\Temp\ccXtHNOY.o:main.cpp:(.text+0x129): >undefined reference tocv::imshow(cv::String const&, cv::_InputArray const&)' c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: >C:\Users\xxx\AppData\Local\Temp\ccXtHNOY.o:main.cpp:(.text+0x149): >undefined reference to
cv::waitKey(int)' c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: >C:\Users\xxx\AppData\Local\Temp\ccXtHNOY.o:main.cpp:(.text$_ZN2cv6StringC1EPKc[__ZN2cv6StringC1EPKc]+0x42): undefined reference tocv::String::allocate(unsigned int)' c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: >C:\Users\xxx\AppData\Local\Temp\ccXtHNOY.o:main.cpp:(.text$_ZN2cv6StringD1Ev[__ZN2cv6StringD1Ev]+0xf): undefined reference to
cv::String::deallocate()' c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: >C:\Users\xxx\AppData\Local\Temp\ccXtHNOY.o:main.cpp:(.text$ZN2cv6StringaSERKS0[__ZN2cv6StringaSERKS0_]+0x1c): undefined reference tocv::String::deallocate()' c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: >C:\Users\xxx\AppData\Local\Temp\ccXtHNOY.o:main.cpp:(.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]+0x2d): undefined reference to
cv::fastFree(void*)'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: >C:\Users\xxx\AppData\Local\Temp\ccXtHNOY.o:main.cpp:(.text$_ZN2cv3Mat7releaseEv[__ZN2cv3Mat7releaseEv]+0x40): undefined reference tocv::Mat::deallocate()' c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: >C:\Users\xxx\AppData\Local\Temp\ccXtHNOY.o:main.cpp:(.text$_ZN2cv3MataSEOS0_[__ZN2cv3MataSEOS0_]+0xb4): undefined reference to
cv::fastFree(void*)' collect2.exe: error: ld returned 1 exit status
Im losing my senses and hope that anyone got idea what's going on
"C:\\OpenCV\\opencv\\build\\x64\\vc15\\lib",
is no good for gcc/mingw. Those are Visual Studio binaries. – drescherjm