[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] math.h linker fejl



On Mon, 23 Apr 2001 19:41:42 +0200, Christian Hemmingsen wrote:

> Har du prøvet at lave dit program i C (ikke C++)? Jeg vil spare dig for det
> og fortælle dig at det ikke virker. Hvorfor C++ kompileren ikke behøver at
> få -lm skal jeg ikke kunne svare på, men sådan er det bare.

Det skyldes at libstdc++ er linket med libm. Så alle C++ programmer som linkes
med det bibliotek (og det gør de automatisk hvis de i linker skridtet kalder
g++) får den automatisk med.

Du kan undgå libstdc++ og libm ved at linke med gcc (selvom at det er et c++
program, ved compileren godt at C++ filer skal oversættes med c++ driveren):

Compilet med: gcc test.C
        libc.so.6 => /lib/libc.so.6 (0x40023000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

med g++ test.C:

        libstdc++-libc6.2-2.so.3 => \
/usr/lib/libstdc++-libc6.2-2.so.3 (0x40023000)
        libm.so.6 => /lib/libm.so.6 (0x40069000)
        libc.so.6 => /lib/libc.so.6 (0x4008b000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)


Du kan se hvad der helt præcist bliver gjort i linker skridtet med at give -v
flaget.



-- 
=======================================================================
<sslug@sslug>           Herlev, Denmark       Software Designer
<URL:http://www.andreasen.org/>       <*>         LASAT^WEicon Networks
=======================================================================


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *