Re: how to exclue libm when compile C++ program with g++?

Discussion in 'C++' started by Victor Bazarov, Aug 2, 2004.

  1. nospam wrote:
    > I have written a C++ program 1.cpp


    The code below is not a valid C++ program.

    >
    > #include <stdioh>


    This should be

    #include <stdio.h>

    or

    #include <cstdio>

    >
    > main() {


    This should be

    int main() {

    > }
    >
    > then I compile with g++ 1.cpp, it generated a ./a.out.
    >
    > [root@backup-server tmp]# ldd ./a.out
    > libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x40027000)
    > libm.so.6 => /lib/tls/libm.so.6 (0x400da000)
    > libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x400fc000)
    > libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
    > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
    >
    > [root@backup-server tmp]# objdump -x a.out | grep NEED
    > NEEDED libstdc++.so.5
    > NEEDED libm.so.6
    > NEEDED libgcc_s.so.1
    > NEEDED libc.so.6
    > VERNEED 0x804822c
    > VERNEEDNUM 0x1
    >
    > why is there libm.so.6??? I dont have any math function called?


    That's compiler-specific. Apparently some kinds of objects declared
    either in <stdio.h> or implicitly by the compiler require a whole bunch
    of other libraries (possibly all being part of the standard library) to
    resolve some other symbols they use. That is not defined by the language
    itself. Actually, how libraries are presented at linking (and whether
    there indeed is 'linking') is not specified.

    >
    > I need to modify an extremely complicated C++ project using only integer
    > and I need to prove to my client that the project does not use libm. However
    > seems I cannot get rid of libm. Could anyone help?


    Somebody in a g++ newsgroup should be able to. Your question has really
    nothing to do with the language and everything to do with a particular
    compiler. Please refer to gnu.g++.help newsgroup.

    Victor
     
    Victor Bazarov, Aug 2, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nospam
    Replies:
    1
    Views:
    464
  2. Lonnie Princehouse
    Replies:
    2
    Views:
    366
    Lonnie Princehouse
    Nov 5, 2005
  3. what does libm.a contain?

    , Jun 26, 2008, in forum: C Programming
    Replies:
    4
    Views:
    548
    David Thompson
    Jul 7, 2008
  4. rembremading

    Intel Compiler 10.1 and LibM Math Library

    rembremading, Oct 24, 2008, in forum: C Programming
    Replies:
    5
    Views:
    396
    Tim Prince
    Oct 24, 2008
  5. Dna Kp
    Replies:
    3
    Views:
    145
    Dna Kp
    Dec 22, 2007
Loading...

Share This Page