2

I have a problem with adding library to my c project in eclipse. I have libraries *.lib which I have to add to my project. I've added them in "paths and symbols-> libraries" (only names of the libraries) and the path to the libraries directory in "paths and symbols-> library path)

I do everything as it is in the user guide but linker shows that he cannot find this libraries. Any ideas?

3
  • You must also add linker flags like -l<library-name> for each library you use. For example, -lACE for libACE.so. Commented Jul 18, 2016 at 9:30
  • when I add library to paths and symbols I have it automatically in the c/c++ build/linker/settings and there is a full directory to the library Commented Jul 18, 2016 at 9:52
  • Indeed. I posted what I found in answer. Commented Jul 18, 2016 at 10:21

1 Answer 1

2

In short:

Edit library from full path to library name like:

<path>/lib<name>.so to <name>

This will lead to linking with flag -l<name> which is right.


I got the same issue as you by following to your steps. I used ACE library for testing.

  • I added ACE library to Project/Properties/C/C++ General/Paths and Symbols/Libraries

  • I added path to libraries to Project/Properties/C/C++ General/Paths and Symbols/Library Paths

After that, in Project/Properties/C/C++ Build/Settings/Libraries I've got:

  • /usr/local/lib/libACE.so as library.
  • /usr/local/lib as library path.

That lead to linking with flag -l/usr/local/lib/libACE.so which isn't right. As I know, there shouldn't be lib prefix when using -l flag.

When I changed /usr/local/lib/libACE.so to ACE in Project/Properties/C/C++ Build/Settings/Libraries, linking went normally.


This is the test code I compiled:

#include <ace/Time_Value.h>

int main() {

    ACE_Time_Value t;
    t.msec(1000);

}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, but it still cannot find this library

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.