C ++: external library in eclipse CDT

Now I use eclipse CDT for my C / C ++ application, but there is a problem when I link my external library, it cannot be loaded properly at runtime, even if I put the library file next to the source file, I gave the path to the library, and he correctly called.

project directory:

  • include (.h files)
  • source (.cpp. files ..)
  • Lib (libbozorth3.a, LSFMatcher.a)

I want a link that static libraries with my application have the following steps:

  • project-> properties-> general-> path and symbols-> include the path to the directory and library (bozorth3.a, LSFMatcher.a) and add the path to the library.
  • and also i add the same library in the linker section as well

When I create a program, it displays an error I cannot find -lbozorth3.a cannot find -lLSFMatcher.a

So, I need the right steps to add an external library to a c / C ++ application.

+6
source share
3 answers

I usually tune

  • library
  • library search path (required for compilation)
  • run-time search path (-rpath Linker option)

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

Library search pathLinker options for runtime search path

+12
source

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

Also in the -l library add a library, for example, for example. for libgcc.a add only gcc

+1
source

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

The method for passing parameters is different. Instead of using:

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

You should use:

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

That is, delete "-Wl" and replace the second "," with "" (space).

enter image description here

enter image description here

0
source

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


All Articles