For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > November 2005 > Static Linking of stdc++ in .so file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Static Linking of stdc++ in .so file
jay

2005-11-23, 3:57 am

I am trying to statically link the stdc++ library in my .so. It gives me
core dump when .so load in executable. While dynamically link stdc++ will
work perfectly fine. My gcc version is 3.3.2.

Can anyone suggest how to link stdc++ libs statically in my .so file ?



Thanks

J


Thobias Vakayil

2005-11-23, 3:57 am

jay wrote:

>I am trying to statically link the stdc++ library in my .so. It gives me
>core dump when .so load in executable. While dynamically link stdc++ will
>work perfectly fine. My gcc version is 3.3.2.
>
>Can anyone suggest how to link stdc++ libs statically in my .so file ?
>
>
>
>Thanks
>
>J
>
>
>
>

While linking the application, use -Bstatic option.

Regards,

Thobias Vakayil

Nilesh

2005-11-23, 7:57 am

I use it like this. Staica linking works fine for me but my so also has
STL functions because of which EXE using so crashes.

g++ -o libMy.so.1.0 -D_DEBUG -g -O3 -static-libgcc -nostdlib ../src/M.d
../src/A.d ../src/C.d -L/usr/lib -L/usr/local/lib -L/usr/ccs/bin
-L/usr/ccs/lib -G -Wl,-Bstatic -lstdc++ -lgcc_eh -lgcc -Wl,-Bdynamic
-lpthread -lposix4 -lc

Hope this helps.
-Nilesh

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com