I tried to compile simple program using OpenCV 4.11 and current version of Mingw on Windows 7. I downloaded binaries for OpenCV from https://github.com/huihut/OpenCV-MinGW-Build. I tried to compile it using command: "g++ main.cpp -std=c++11 -I F:\cpp_tools\libs\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\include -L F:\cpp_tools\libs\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\x64\mingw\lib -lopencv_core411.dll -lopencv_imgcodecs411.dll -lopencv_imgproc411.dll -lopencv_highgui411.dll -o myprog.exe"
and i got linker error:
C:\Users\Radek\AppData\Local\Temp\ccyTSmo1.o:main.cpp:(.text+0xa0): undefined re
ference to cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, int)'
C:\Users\Radek\AppData\Local\Temp\ccyTSmo1.o:main.cpp:(.text+0x13e): undefined r
eference to
cv::namedWindow(std::__cxx11::basic_string, std::allocator > const&, int)'
C:\Users\Radek\AppData\Local\Temp\ccyTSmo1.o:main.cpp:(.text+0x19f): undefined r
eference to cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, cv::_InputArray const&)'
C:\Users\Radek\AppData\Local\Temp\ccyTSmo1.o:main.cpp:(.text+0x1c9): undefined r
eference to
cv::waitKey(int)'
C:\Users\Radek\AppData\Local\Temp\ccyTSmo1.o:main.cpp:(.text$_ZN2cv3MatD1Ev[__ZN
2cv3MatD1Ev]+0x2d): undefined reference to cv::fastFree(void*)'
C:\Users\Radek\AppData\Local\Temp\ccyTSmo1.o:main.cpp:(.text$_ZN2cv3Mat7releaseE
v[__ZN2cv3Mat7releaseEv]+0x40): undefined reference to
cv::Mat::deallocate()'
C:\Users\Radek\AppData\Local\Temp\ccyTSmo1.o:main.cpp:(.text$ZN2cv3MataSEOS0[_
ZN2cv3MataSEOS0]+0xb4): undefined reference to `cv::fastFree(void*)'
collect2.exe: error: ld returned 1 exit status
I read alot of similar problems but any of it didn't solved my problem.
Source code:
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
#include <string>
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
String imageName( "../data/HappyFish.jpg" ); // by default
if( argc > 1)
{
imageName = argv[1];
}
Mat image;
image = imread( imageName, IMREAD_COLOR ); // Read the file
if( image.empty() ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", WINDOW_AUTOSIZE );
imshow( "Display window", image );
waitKey(0); // Wait for a keystroke in the window
return 0;
}