Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » How to link static libraries?
How to link static libraries? [message #159653] Thu, 01 December 2005 05:17 Go to next message
Eclipse UserFriend
Originally posted by: gabry.ian.ge.cnr.it

I'd like to link a static library in a managed make project. I can't find
a way to do it in the IDE. Has someone a hint for me?
Many thanks in advance,
Gabry
Re: How to link static libraries? [message #159660 is a reply to message #159653] Thu, 01 December 2005 07:14 Go to previous messageGo to next message
Eclipse UserFriend
Project->Properties->C/C++ Build->Tool Settings->Gcc C linker->Libraries

To add the library libX.a, add X to the Libraries list. You might also
want to add the directory this file is located to the Libraries Search
Path.

Kurt.
Re: How to link static libraries? [message #159815 is a reply to message #159660] Sat, 03 December 2005 06:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: void.void.com

Kurt Dirix wrote:
> Project->Properties->C/C++ Build->Tool Settings->Gcc C linker->Libraries
>
> To add the library libX.a, add X to the Libraries list. You might also
> want to add the directory this file is located to the Libraries Search
> Path.
>
> Kurt.
>

Doesn't this result in the library being linked dynamically? I think if
you doesn't tell 'ld' anything specific, it will link dynamically by
default. IIRC you have to link the library using -Bstatic if you want it
to be compiled into your output file(s).

Regards,
Matthias
Re: How to link static libraries? [message #159902 is a reply to message #159815] Mon, 05 December 2005 03:33 Go to previous messageGo to next message
Eclipse UserFriend
No.

After linking, you do not need to have access to libX.a any more. If a
library is compiled as static, it does not contain the information needed
to be accessed dynamically (sort of,... I'm not a guru (haha! the
thought!)).

You can use the same command to link to a DLL; in that case the linking
will be dynamically.
Re: How to link static libraries? [message #159917 is a reply to message #159902] Mon, 05 December 2005 10:19 Go to previous message
Eclipse UserFriend
Originally posted by: gabry.ian.ge.cnr.it

Many thanks to both Kurt and Matthias. I partially solved my problem using
both your hints... If I add the library I need (pthread) in
Project->Properties->C/C++ Build->Tool Settings->Gcc C linker->Libraries I
obtain a dinamically linked executable. If I also add the option -static
in Project->Properties->C/C++ Build->Tool Settings->Gcc C
linker->Miscellaneous->Linker flags I obtain a statically linked
executable.
Unfortunately I don't have completely solved my problem yet because in the
first case the library that is dinamically linked is the NPTL 2.3.5 while
in the second case the library that is statically linked is
Linuxthreads-0.10 and I don't understand why this happens... I'd like to
have the possibility to specify the library I want (NPTL or Linuxthreads)
both in the static and dynamic linking case. Do you have any idea about
how forcing the linking with a particular static/dynamic library?

My kindest regards,
Gabry
Previous Topic:Won't Recognise Makefile
Next Topic:SPARC Simulator + GDB + CDT + Eclipse
Goto Forum:
  


Current Time: Sun Jul 27 16:13:49 EDT 2025

Powered by FUDForum. Page generated in 0.03834 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top