static libstdc++.so.5

static libstdc++.so.5

Post by Markus Wenk » Fri, 21 Mar 2003 23:48:03



Hi,

I want to link my App static with libstdc++.so.5 (inkc. libgcc_s.so.1)
I usee gcc 3.2. If I use the param "-static" ld tries to link my dyn
libs static, and I don't want that.

thanks in advance

Markus

 
 
 

static libstdc++.so.5

Post by Steven Rosted » Fri, 21 Mar 2003 23:52:51



> Hi,

> I want to link my App static with libstdc++.so.5 (inkc. libgcc_s.so.1)
> I usee gcc 3.2. If I use the param "-static" ld tries to link my dyn
> libs static, and I don't want that.

First, libstdc++.so.5 will not be linked static. You need libstdc++.a.

Anyway, the -static parameter must come after your dynamic libraries
that you specify.

ie:

gcc -o myprog myproc.c -lmydym1 -lmydym2 -static

-- Steve

 
 
 

static libstdc++.so.5

Post by Markus Wenk » Fri, 21 Mar 2003 23:58:47




>> Hi,

>> I want to link my App static with libstdc++.so.5 (inkc. libgcc_s.so.1)
>> I usee gcc 3.2. If I use the param "-static" ld tries to link my dyn
>> libs static, and I don't want that.

> First, libstdc++.so.5 will not be linked static. You need libstdc++.a.

> Anyway, the -static parameter must come after your dynamic libraries
> that you specify.

> ie:

> gcc -o myprog myproc.c -lmydym1 -lmydym2 -static

It doesn't work, ld says "cannot find -lmydym1"
 
 
 

static libstdc++.so.5

Post by Steven Rosted » Sat, 22 Mar 2003 00:53:48




>> ie:

>> gcc -o myprog myproc.c -lmydym1 -lmydym2 -static

> It doesn't work, ld says "cannot find -lmydym1"

I'm assuming you don't actually mean mydym1 and are substituting
mydym1 with your actual dynamic library.

So if you have libmydym.so in your current directory, you should
do the following:

g++ -o myprog myproc.cc -L. -lmydym -static

The -L. tells the linker to look into your current (".")
directory, you could also specify a path like -L/my/dynamic/dir/path
Note that to run this program, you either need to place your dynamic
library into one of the directories in /etc/ld.so.conf, add a directory
to /etc/ld.so.conf or update your LD_LIBRARY_PATH environment variable
to include the path your dynamic library is placed.  The first two
require root priviledges and to run ldconfig, whereas the environment
variable change can be done by anyone.

If you do the environment var change, then you need to make sure it is
exported and the format is just like the PATH variable.

-- Steve