help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Linking only one library statically?


From: Paul Pluzhnikov
Subject: Re: Linking only one library statically?
Date: 30 Jan 2005 08:01:31 -0800
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence)

Matthias <nospam@digitalraid.com> writes:

> I know that ld has a flag called static.

Only *some* ld's understand '-static'. It is not a "universally
understood" flag.

Gcc/g++ always understands '-static' and translates it into the
appropriate linker flags are OS depend.

> But what if I don't want ALL
> libs to be statically linked, but only some?

It is impossible to answer your question without knowing the OS.
However, taking an educated guess that you are on Linux, the
answer is:

   g++ ... main.o ... -Wl,-Bstatic -lboost -Wl,-Bdynamic -lgtkmm ...

Be sure *not* to do this:

   g++ ... main.o ... -lgtkmm -Wl,-Bstatic -lboost

The above is wrong because it leaves '-Bstatic' "hanging". It will
cause other libraries (e.g. libc, libstdc++, which are added to
the link line by 'g++') to be linked statically as well, and
will result in much grief later on.

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]