mingw32-make Undefined reference to ...
So I have OpenCV libraries downloaded from here https://sourceforge.net/projects/open...
CMake gui with cmakelist.txt like this
cmake_minimum_required(VERSION 2.8)
project(Display)
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:") message(STATUS " config: ${OpenCV_DIR}") message(STATUS "
version: ${OpenCV_VERSION}") message(STATUS " libraries: ${OpenCV_LIBS}") message(STATUS "
include path: ${OpenCV_INCLUDE_DIRS}")add_executable(Display DisplayImage.cpp)
target_link_libraries(Display ${OpenCV_LIBS})
and have a simple cpp like this
#include <stdio.h>
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc, char** argv )
{
// cout << "You have entered " << argc
// << " arguments:" << "\n";
// for (int i = 0; i < argc; ++i)
// cout << argv[i] << "\n";
// cout << "a" << argv[1];
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);
printf("Hello World!");
return 0;
}
already configure it with cmake-gui and this shows up
OpenCV library status: config: D:/opencv/build/x64/vc15/lib version: 3.4.6 libraries: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_shape;opencv_stitching;opencv_superres;opencv_video;opencv_videoio;opencv_videostab;opencv_world include path: D:/opencv/build/include;D:/opencv/build/include/opencv;D:/opencv/build/include/opencv2 Configuring done Generating done
seems good right ? and then on the build directory from command prompt, i typed mingw32-make
and this shows up
CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text+0x72): undefined reference to
cv::imread(cv::String const&, int)' CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text+0xe3): undefined reference to
cv::namedWindow(cv::String const&, int)' CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text+0x129): undefined reference tocv::imshow(cv::String const&, cv::_InputArray const&)' CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text+0x149): undefined reference to
cv::waitKey(int)' CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text$_ZN2cv6StringC1EPKc[__ZN2cv6StringC1EPKc]+0x42): undefined reference tocv::String::allocate(unsigned int)' CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text$_ZN2cv6StringD1Ev[__ZN2cv6StringD1Ev]+0xf): undefined reference to
cv::String::deallocate()' CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text$_ZN2cv6StringaSERKS0_[__ZN2cv6StringaSERKS0_]+0x1c): undefined reference tocv::String::deallocate()' CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]+0x2d): undefined reference to
cv::fastFree(void)' CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text$_ZN2cv3Mat7releaseEv[__ZN2cv3Mat7releaseEv]+0x40): undefined reference tocv::Mat::deallocate()' CMakeFiles\Display.dir/objects.a(DisplayImage.cpp.obj):DisplayImage.cpp:(.text$_ZN2cv3MataSEOS0_[__ZN2cv3MataSEOS0_]+0xb4): undefined reference to
cv::fastFree(void)' collect2.exe: error: ld returned 1 exit status mingw32-make[2]: * [CMakeFiles\Display.dir\build.make:104: Display.exe] Error 1 mingw32-make[1]: [CMakeFiles\Makefile2:72: CMakeFiles/Display.dir/all] Error 2 mingw32-make: ** [Makefile:83: all] Error 2
how do i fix this ? or is it because that i use the library straight from the ...
the prebuilt libs from sf are for VS only, you cannot use those with mingw
do i have to make opencv library for mingw first ? Thanks btw
yes, you have to build the opencv libs from src first. please use the search bar here to find out how.
so.. i downloaded the library from here https://github.com/huihut/OpenCV-MinG... but when everything is done, it says it needs qt5core.dll and other qt5 dll. why is opencv need qt5 dll ? Thanks again btw, you're really helping
actually i just made my own library using mingw and it worked, but i will still appreciate if u answer my question about the qt part.
big thanks