[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: howto select the static version of a library with -l (but not for al
From: |
Paul Pluzhnikov |
Subject: |
Re: howto select the static version of a library with -l (but not for all the other libraries) |
Date: |
Mon, 07 Aug 2006 20:32:11 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) |
Sid Touati <Sid-pasdespam.Touati-nospam@inria-nospam.fr> writes:
> To give a concrete example, suppose that I have a g++ compiler command
> line such as :
> g++ -O0 -g3 -o sira sira.o RG.o intLPSIRA.o siraloop.o anyoption.o
> -L/home/touati/lib -L/usr/ilog/cplex100/lib/x86_rhel4.0_3.4/static_pic
> -L/home/touati/lp_solve_5.5/lib -L/usr/lib -llpsolve55 -lpthread -lm
> -lcplex -lDDG -lG -lL -lboost_filesystem
This command line is bad -- system libraries (libpthread,
libm) should go after all "user" libraries.
This may be important because the order of library
initialization is generally reverse of their order on the
link line.
> And I would like to select the static version of
> libboost_filesystem.
The answer is platform-specific. On many platforms the
following will do what you want:
g++ ... -Wl,-Bstatic -lboost_filesystem -Wl,-Bdynamic ...
> experimented two solutions :
> - with -static g++ option : this option makes g++ to consider static
> libraries for all other libraries.
Don't ever use completely static linking (which is what
gcc -static does) -- it produces binaries that are likely
to fail across even subminor system revision differences.
> - by providing libboost_filesystem.a as a direct object file to the
> line command, but this solution would not be portable to all UNIX
> platforms.
Name a UNIX platform to which this solution is not portable.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.