Using OpenCV in Eclipse (getting started)

I want to use OpenCV in Eclipse Neon for C ++. Unfortunately, when creating a project, some binding errors occur.

I completed this tutorial and completed the following steps:

  • Install Eclipse Neon for C / C ++ (Windows 64-bit) http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/neon1a

  • MinGW installation (mingw-get-setup.exe, https://sourceforge.net/projects/mingw/files/Installer/) in the C: \ MinGW folder

  • Installing OpenCV 3.1 for Windows (http://opencv.org/downloads.html) in the C: \ opencv folder

  • Creating a new and empty C ++ project in eclipse

  • Adding inclusions and libaries as described in the tutorial

  • Adding the source file Test.cpp, which gives no errors

    #include <opencv2/highgui/highgui.hpp>
    #include <iostream>

    using namespace cv;
    using namespace std;

    int main(int argc, char** argv)
    {
      Mat im = imread(argc == 2 ? argv[1] : "lenna.png", 1);
      if (im.empty())
      {
        cout << "Cannot open image!" << endl;
        return -1;
      }
      imshow("image", im);
      waitKey(0);
      return 0;
    }
  • Project building

Building a project returns the following errors:

19:00:45 **** Incremental Build of configuration Release for project OpenCV ****
Info: Internal Builder is used for build
g++ "-IC:\\opencv\\build\\include" -O3 -Wall -c -fmessage-length=0 -o Test.o "..\\Test.cpp" 
g++ "-LC:\\opencv\\build\\x64\\vc12\\lib" "-LC:\\opencv\\build\\x64\\vc14\\lib" -o OpenCV.exe Test.o -lopencv_world310 
Test.o:Test.cpp:(.text$_ZN2cv6StringC1EPKc[__ZN2cv6StringC1EPKc]+0x2d): undefined reference to `cv::String::allocate(unsigned int)'
Test.o:Test.cpp:(.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]+0x15): undefined reference to `cv::Mat::deallocate()'
Test.o:Test.cpp:(.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]+0x6d): undefined reference to `cv::fastFree(void*)'
Test.o:Test.cpp:(.text.startup+0x4f): undefined reference to `cv::imread(cv::String const&, int)'
Test.o:Test.cpp:(.text.startup+0x56): undefined reference to `cv::String::deallocate()'
Test.o:Test.cpp:(.text.startup+0xc0): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
Test.o:Test.cpp:(.text.startup+0xc7): undefined reference to `cv::String::deallocate()'
Test.o:Test.cpp:(.text.startup+0xd3): undefined reference to `cv::waitKey(int)'
Test.o:Test.cpp:(.text.startup+0x134): undefined reference to `cv::String::deallocate()'
Test.o:Test.cpp:(.text.startup+0x161): undefined reference to `cv::String::deallocate()'
collect2.exe: error: ld returned 1 exit status

19:00:45 Build Finished (took 781ms)

?

!

0

Source: https://habr.com/ru/post/1657817/


All Articles