This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: static runtime linking and libgcc/libgcc_s


Daniel Jacobowitz wrote:

>> But in 3.3 I can not do it any longer. Unless there '-static' option, gcc
>> add "lgcc_s" library to the collect2 invocation. That library exists only
>> as shared object, so if I have "-Wl,-Bstatic", it's just not found.
>> 
>> OTOH, if I specify -static, then all libraries will be statically linked,
>> not only implicitly added ones.
>> 
>> So, does anybody knows a solution?
> 
> -static-libgcc will take care of libgcc_s.so.  You'll have to handle
> libstdc++ some other way.

Hi Daniel,
thanks for the help. To deal with other libraries I've tried 

   g++ -shared -o lib1.so lib1.cpp -static-libgcc -Wl,-Bstatic
   g++ -o app app.cpp lib1.so -static-libgcc -Wl,-Bstatic

and get:

   bash-2.05b$ ldd app
        lib1.so => lib1.so (0x40014000)

I.e. only user library is dynamically linked. So far, so good, but running
'app' gives strange error:

    bash-2.05b$ ./app
    Inconsistency detected by ld.so: dl-fini.c: 66: _dl_fini: Assertion `i
     == _rtld_local._dl_nloaded' failed!

Any ideas what wrong here? "lib1.cpp" has only one empty function and
"app.cpp" has only main which calls function from "lib1.cpp". The exact
content is on 
http://www.boost-consulting.com/boost/tools/build/examples-v2/libraries/app/app.cpp
http://www.boost-consulting.com/boost/tools/build/examples-v2/libraries/lib1/lib1.cpp

TIA,
Volodya



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]