8

Now I am using eclipse CDT for my C/C++ Application, but there is problem when I link my external library, it could not be loaded properly at run time, even through I put the library file near the source file, I gave the library path, and it's name correctly.

project directory:

  1. include(.h files)
  2. source(.cpp. files..)
  3. lib(libbozorth3.a,LSFMatcher.a)

I want link that static libraries with my application I follow this steps:

  1. project->properties->general->path and symbols->include directory path,and libraries(bozorth3.a,LSFMatcher.a),and add library path .
  2. and also i add the same library in linker section also

When I build the program it displays a error cannot find -lbozorth3.a cannot find -lLSFMatcher.a

So I need the correct steps to add the external library to c/c++ application.

Victor
  • 8,309
  • 14
  • 80
  • 129
Mr.Cool
  • 1,525
  • 10
  • 32
  • 51
  • did you consider: http://stackoverflow.com/questions/8370809/how-to-add-a-library-to-eclipse-c-project ? – Dyonisos Jan 12 '12 at 13:34

3 Answers3

13

I normally configure

  1. the library
  2. the library search path (Needed for compiliation)
  3. the runtime search path (-rpath Linker option)

(see images below and exchange the path in the Linker flags to that one you used in the library search path)

Library Search path Linker options for runtime search path

FSaccilotto
  • 656
  • 8
  • 13
2

you should use -Wl,-rpath=${workspace_loc}/Liball and not -Wl,-rpath,${workspace_loc}/Liball.

Also under library -l option add library like eg. for libgcc.a add only gcc

Code Lღver
  • 15,573
  • 16
  • 56
  • 75
Rahul Ravi
  • 21
  • 1
  • This is not a full answer. It depends on the answer offered by FSaccilotto. Maybe you should move it to a comment so he can correct his post, or you should add more detail to yours so it is a full answer. – Dzyann Jul 22 '14 at 16:28
0

You should pay attention to what is in parentheses: Other options (-Xlinker [option]).

The way to pass options is different. Instead of using:

-Wl,-rpath,'${ProjDirPath}/../../system/lib'

You must use:

-rpath '${ProjDirPath}/../../system/lib'

That is, remove the "-Wl," and replace the second "," by " " (space).

enter image description here

enter image description here

lopes
  • 549
  • 5
  • 13