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

G++/ld and static/dynamic mix



Hi,
I'm having a problem with my code and linking.  My desire is to create an
executable that will run on the many different distributions of Linux
around.  That should be easily done by putting the -static flag in the g++
call.  Unfortunately I have to link in certain shared libraries from a
vendor.  So, when I put the -static flag in, the compiler aborts since it
can't find the .a files for these external libraries.  I've tried adding
the -Wl,-Bdynamic and -Wl,-Bstatic flags around the libraries in question,
but when I run ldd on the resulting executable, it still shows libm, libc,
and libstdc++ as being dynamically linked.

As far as I can tell I have these options:

1)  Convert my dynamic libraries into static ones and compile with the
-static flag.

2)  Figure out how to get everything (including libstdc++, libc, and libm)
to link statically except for my vendor-supplied libraries.

3)  Create different executables for each distro.


For those of you who are wondering why my executables compiled on one
distro don't work on another--the libstdc++... library has different names
on different platforms.  If I link the existing libstdc++ version to one
with the correct name, it works, but I think that this is a VERY BAD
THING.

Anyway, any help that you can provide would be most appreciated--I hate
having to compile in three different places to provide the same
executable.


Thanks


-- 
-bob


Hurewitz's Memory Principle:  The chance of forgetting something
         is directly proportional to... to... uh.....
**********************************************************************
* Robert Kerr, The morphing guy.  *    MS 0847 Sandia National Labs  *
* rakerr@sandia.gov               *    Albuquerque NM 87185-0847     *
* Robert_Kerr@byu.edu             *      Phone: (505) 844-8606       *
* http://www.et.byu.edu/~kerrr    *      Fax: (505) 844-9297         *
**********************************************************************




Reply to: