user3684792
user3684792

Reputation: 2611

ld: library not found for - Eclipse

I am trying to link against a 3rd party library using eclipse. I have build the library, and specified where it is on my machine using properties/paths and symbols/libraries. From this menu, I used the gui to select the location of the .a file. However, on running I still receive the error:

ld: library not found for -l/path_to_library_that_I_selected...

Any thoughts on what could be causing this / things to try?

Cheers

Upvotes: 1

Views: 5587

Answers (2)

Tim Johnsen
Tim Johnsen

Reputation: 180

Project > Properties > C/C++ Build > Settings > Tool Settings > C++ Linker > Libraries

Under Library search path (-L) put the path to the folder where your lib file is. Under Libraries (-l) put the name of the lib file, do not include the "lib" prefix at beginning of file name or the file extension.

Example: you want to use the lib file "usr/local/Cellar/opencv/3.4.2/lib/libopencv_ml.a" in Library search path put "usr/local/Cellar/opencv/3.4.2/lib" in Libraries put "opencv_ml"

Upvotes: 3

vsoftco
vsoftco

Reputation: 56577

You probably need to add -L (CAPITAL L) flag, to specify the path to your library, like -L /my/path/to/library (as I believe it is not installed in a standard location like /usr/local/lib ). -l flag is just for the name of the library, not the path. Go to Project Options/C++ linker, then you can add the flags there, under "Libraries" and "Library search path".

A screenshot example:

enter image description here

Upvotes: 4

Related Questions