Eclipse can't find includes, looking in the wrong place

Hi,

I want to ask a question about my recent attempt to configure OpenCV with Eclipse. After configuring, generating and installing a MinGW-based makefile opencv project, launching it shows Eclipse can't find the opencv include files to build the new project. In fact Eclipse is using a MingW path I don't recall setting. I need some assistance to move on into the programming phase - stuck here. I've even tried hard coding an include for testing and Eclipse still can't find the include.

Here are the link errors:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Info: Internal Builder is used for build
g++ "-LC:\\opencv_src\\opencv-3.4.0\\Mingw_build\\install\\x64\\mingw\\lib" -static -o hello_Eclipse_opencv.exe "src\\helloopencv.o" "-lopencv_calib3d340 " "-lopencv_core340 " -lopencv_flann340 -lopencv_highgui340 -lopencv_imgcodecs340 -lopencv_imgproc340 "-lopencv_ml340 " "-lopencv_objdetect340 " "-lopencv_features2d340 " "-lopencv_photo340 " -lopencv_shape340 
C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_calib3d340 
C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_core340 
C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_flann340
C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_highgui340
C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_imgcodecs340
C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_imgproc340
C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_ml340 
C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_objdetect340 
C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_features2d340 
C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_photo340 
C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_shape340
collect2.exe: error: ld returned 1 exit status


I also tried hard-coding an include with an error:

1
2
fatal error: C:\opencv_src\opencv-3.4.0\Mingw_build\install\include\opencv2\core.h: No such file or directory


This code was posted to path:

 
C:\opencv_src\Mingw_build\install\x64\mingw\bin


I dont know why its looking here:
 
C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopencv_shape340
Last edited on
> it shows Eclipse can't find the opencv include files to build the new project
No, it doesn't.

> In fact Eclipse is using a MingW path I don't recall setting.
The "path" you are showing is the path to the linker. You can tell this by noting the "ld.exe" at the end of it. The message is that the linker cannot find the libraries you are specifying. Ensure that they exist in the directory you've told it to look in.

The linker is called after all of the code in your project has been compiled (therefore, it found all of the include/header files necessary for compilation.)
> "-lopencv_calib3d340 "
¿why that space at the end?

-l is just a shortcut, you may write the full path to the library
g++ C:\\opencv_src\\opencv-3.4.0\\Mingw_build\\install\\x64\\mingw\\lib\\libopencv_calib3d340.a
Hi Cire Thanks for answering!

My library path (-L) is entered this way, in the Eclipse linker c++ settings:

"C:\opencv_src\opencv-3.4.0\Mingw_build\install\x64\mingw\bin"

However its searching

C:/minGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/bin/

Why? I've got it searching the OpenCV install, but no it isn't.

Hey Ne555 how do I execute that statement (in my IDE)?:
g++ C:\\opencv_src\\opencv-3.4.0\\Mingw_build\\install\\x64\\mingw\\lib\\libopencv_calib3d340.a
I don’t know what happened but I rebuilt the library, making sure Eclipse was pointing to all of the correct libs/bins, made sure all header files were included. Maybe the most important was making sure I had a path in the main system the pointed to both the bin & lib folders. Cleaned out a few paths that weren’t used anymore. And boom, we have launch (except I don’t know where the image/image file is) for demo.

The build was also missing a lib folder in the install directory.

[includes]
x64
.
mingw
.
bin
lib
Last edited on
The problem may be that you are trying to use a relative path. It would have to be relative to the directory where make is running the GCC linker. Try using the full path to the libraries. If you think you must use relative paths, temporarily change the linker command to display the current working directory then calculate the necessary relative path to it from the working directory of the link.
http://www.cetpainfotech.com/technology/c-language-training
Topic archived. No new replies allowed.