I am a few days ago trying to install opencv using Dev-Cpp and Windows 10, i add the directories of the.h, .lib and.dll files to the Dev-Cpp, but when i compile the code always give me the same error.
In compiler options i add the next directories:
-C++ Headers--
C:\Users\admin\Downloads\opencv\build\include
-Libraries-
C:\Users\admin\Downloads\opencv\build\x64\vc15\lib
-Binary files-
C:\Users\admin\Downloads\opencv\build\x64\vc15\bin
-Code-
#include <iostream>
#include <opencv2/imgcodecs.hpp>
int main(){
cv::Mat img;
img = cv::imread("Goten.jpg");
return 0;
}
-Errors-
c:\mingw\mingw32\bin\ld.exe C:\Users\admin\AppData\Local\Temp\cciHfDkS.o:main.cpp:(.text+0x62): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
c:\mingw\mingw32\bin\ld.exe C:\Users\admin\AppData\Local\Temp\cciHfDkS.o:main.cpp:(.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]+0x2d): undefined reference to `cv::fastFree(void*)'
c:\mingw\mingw32\bin\ld.exe C:\Users\admin\AppData\Local\Temp\cciHfDkS.o:main.cpp:(.text$_ZN2cv3Mat7releaseEv[__ZN2cv3Mat7releaseEv]+0x40): undefined reference to `cv::Mat::deallocate()'
c:\mingw\mingw32\bin\ld.exe C:\Users\admin\AppData\Local\Temp\cciHfDkS.o:main.cpp:(.text$_ZN2cv3MataSEOS0_[__ZN2cv3MataSEOS0_]+0xb4): undefined reference to `cv::fastFree(void*)'
C:\Users\admin\Desktop\Programacion\collect2.exe [Error] ld returned 1 exit status
I have installed MinGW 9.2.0, i tried compile it with the standards C++11, C++14 and C++17
What can i do to fix this error? - Sorry for my english
Those are linker errors: it means the compiler can't find the binary code for those functions.
In other words, you might have forgotten to specify a few OpenCV libraries. If I'm not mistaken, imread()
resides in opencv_imgcodecs .
Does vcpkg on Windows require VisualStudio, or does it also work with MinGW? (Doing a very quick Google search seems to show it might work.) Cause ever since I discovered vcpkg
, I must admit that I'd never go back to installing and building things the old way.
Now, to get almost anything on windows, I'd clone the vcpkg repo , run the bootstrap script, and then run vcpkg.exe install opencv
.
Consider using a good source code editor (perhaps GNU emacs ) and compile on the command line (eg by using a build automation tool such as GNU make or ninja ) in a terminal emulator.
Then MinGW is actually some command with g++
or g++.exe
Then you just can download the source code of OpenCV and compile it in some terminal emulator. Or even better, get the source code from github . The compilation of OpenCV from source code could last a dozen of minutes or an hour of computer time/
BTW, if you really are interested in programming OpenCV, I recommend installing a Linux distribution (eg Debian ). Most GNU/Linux systems have a genuine and recent GCC , not just an emulation of GCC called MinGW.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.