how to link statically to C++ runtime libs?

This is a discussion on how to link statically to C++ runtime libs? within the aix forums in Operating Systems category; Hi, i want to remove runtime libs so i am trying to link statically to C++ libs but its not working :-( cat t.cpp #include using namespace std; int main (int argc, char **argv) { cout...

Go Back   Database Forum > Operating Systems > aix

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 10-27-2008, 07:58 AM
Default how to link statically to C++ runtime libs?

Hi,

i want to remove runtime libs so i am trying to link statically to C++
libs but its not working :-(

cat t.cpp
#include

using namespace std;

int main (int argc, char **argv)
{
cout << "test\n\n";

return 0;
}


i used following link line:


/usr/vacpp/bin/xlC -o t t.cpp -bnso -bstatic -lC_r -bstatic -lC -
bdynamic -lpthreads -lc_r -brtl


but still it show dependency on libC.a:


ldd t
t needs:
/usr/vacpp/lib/libC.a(shr.o)
/usr/vacpp/lib/libC.a(shr2.o)
/usr/vacpp/lib/libC.a(shr3.o)
/usr/vacpp/lib/libC.a(ansi_32.o)
/usr/lib/libpthreads.a(shr_comm.o)
/usr/lib/libpthreads.a(shr_xpg5.o)
/usr/lib/libc_r.a(shr.o)
/usr/lib/librtl.a(shr.o)
/usr/vacpp/lib/libC.a(ansicore_32.o)
/usr/vacpp/lib/libC.a(shrcore.o)
/usr/lib/libc.a(shr.o)
/unix
/usr/lib/libcrypt.a(shr.o)

please advice.



Thanks,
Mehul

Reply With Quote
  #2  
Old 10-30-2008, 03:09 PM
Default Re: how to link statically to C++ runtime libs?

mchoube-at-gmail.com wrote:
> Hi,
>
> i want to remove runtime libs so i am trying to link statically to C++
> libs but its not working :-(


First of all, don't.

Secondly, don't.

You're going to have a dependence upon runtime libs (on AIX) whether you
like it or not. What possible difference can one additional library
make? Besides, I think it's unsupported....

> i used following link line:
>
>
> /usr/vacpp/bin/xlC -o t t.cpp -bnso -bstatic -lC_r -bstatic -lC -
> bdynamic -lpthreads -lc_r -brtl


You don't need to add -lC or -lC_r. Use either xlC or xlC_r to build
your app. If you're using threads, the _r compiler adds -lpthreads for
you. And you will never successfully combine runtime linking with a
static link.

Reply With Quote
  #3  
Old 10-31-2008, 05:14 AM
Default Re: how to link statically to C++ runtime libs?

let me re-frame the question correctly.

i want my utility to have run-time dependency on my custom libs but
not on C++ standard libs like libC_r and libC so i want to link
statically to libC_r and libC. but the following link line just works
for libC_r.

/usr/vacpp/bin/xlC -o t t.cpp -bnso -bstatic -lC_r -bstatic -lC -
bdynamic -lpthreads -lc_r -brtl

please advice.

Gary,
Thanks for replying but its a must have for me. i think it should
be possible to link statically to standard C++ libs.



Thanks,
Mehul

Reply With Quote
  #4  
Old 11-05-2008, 10:51 AM
Default Re: how to link statically to C++ runtime libs?

mchoube-at-gmail.com wrote:
> let me re-frame the question correctly.
>
> i want my utility to have run-time dependency on my custom libs but
> not on C++ standard libs like libC_r and libC so i want to link
> statically to libC_r and libC. but the following link line just works
> for libC_r.


I understood your question. The answer is, that's not supported.
It may not even be possible. Certain features in the implementation
don't work with static linking, so it's just not going to happen.

> Gary,
> Thanks for replying but its a must have for me. i think it should
> be possible to link statically to standard C++ libs.


I appreciate how disappointing it is when we don't get what we want,
but no, it's not supported and I'm pretty sure not even possible.
FWIW I did give this a try and I can't do build your tiny app
statically. And frankly, if I can't do it myself it likely can't be
done.
Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 10:58 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Integrated by bbpixel2009 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.