Ask Your Question

Revision history [back]

mingw32-make Undefined reference to ...

So I have OpenCV libraries downloaded from here https://sourceforge.net/projects/opencvlibrary/files/3.4.6/opencv-3.4.6-vc14_vc15.exe/download

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 website ? i also try something like putting a wrong parameter on the imread function and then type mingw32-make and it did tell me that i use a wrong parameter. If they know i used the wrong parameter, then why they can't tell what is imread for (or why is it undefined reference ? ) ? I'm using windows.

I'm very new to these libraries, mingw, and cmake, so i'm sorry if my question is stupid.

mingw32-make Undefined reference to ...

So I have OpenCV libraries downloaded from here https://sourceforge.net/projects/opencvlibrary/files/3.4.6/opencv-3.4.6-vc14_vc15.exe/download

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 website ? i also try something like putting a wrong parameter on the imread function and then type mingw32-make and it did tell me that i use a wrong parameter. If they know i used the wrong parameter, then why they can't tell what is imread for (or why is it undefined reference ? ) ? I'm using windows.

I'm very new to these libraries, mingw, and cmake, so i'm sorry if my question is stupid.