how to link statically to C++ runtime libs? - Aix

This is a discussion on how to link statically to C++ runtime libs? - Aix ; 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 return 0; } i ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: how to link statically to C++ runtime libs?

  1. 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


  2. Re: how to link statically to C++ runtime libs?

    mchoube@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.


  3. 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


  4. Re: how to link statically to C++ runtime libs?

    mchoube@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 to Thread