mingw32-make Undefined reference to ...

asked 2019-04-16 10:29:11 -0600

Invidia18 gravatar image

updated 2019-04-16 10:40:33 -0600

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 to cv::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 to cv::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 to cv::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 to cv::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 ... (more)

edit retag flag offensive close merge delete

Comments

the prebuilt libs from sf are for VS only, you cannot use those with mingw

berak gravatar imageberak ( 2019-04-16 11:46:48 -0600 )edit

do i have to make opencv library for mingw first ? Thanks btw

Invidia18 gravatar imageInvidia18 ( 2019-04-16 15:12:41 -0600 )edit

yes, you have to build the opencv libs from src first. please use the search bar here to find out how.

berak gravatar imageberak ( 2019-04-17 01:23:26 -0600 )edit

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

Invidia18 gravatar imageInvidia18 ( 2019-04-17 07:25:26 -0600 )edit

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

Invidia18 gravatar imageInvidia18 ( 2019-04-17 11:07:33 -0600 )edit