Find the answer to your Linux question:
Results 1 to 4 of 4
Is the C compiler set up to automatically locate the standard libraries? Maybe an example will clarify what I need to know. If we have a C program with the ...
  1. #1
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714

    C standard libraries

    Is the C compiler set up to automatically locate the standard libraries? Maybe an example will clarify
    what I need to know.

    If we have a C program with the include statements:

    #include <stdio.h>
    #include <stdlib.h>

    you would compile this using gcc -o cfilename cfilename.c

    But if you had a C program with include statements:

    #include <stdio.h>
    #include <stdlib.h>
    #include <dlfcn.h>

    you would compile this using gcc -o cfilename cfilename.c -ldl
    to inforn the compiler to include the library for dlfcn.h.

    Now my question is does the compiler, if set up correctly, know where to look for the standard libraries automatically? Or is there something else going on here?

  2. #2
    Linux Newbie
    Join Date
    Nov 2007
    Location
    Planet Earth
    Posts
    152
    Setup the correct environmet variable: Environment Variables - Using the GNU Compiler Collection (GCC)

    Hugo
    EOF

  3. #3
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    So the quick and dirty answer is that libc.so is automatically linked against. You do not need to specify this library. Note, however, that math.h functions are defined inside of libm.so, and this is why you need "-lm" when you use math functions.

    Make sense?
    DISTRO=Arch
    Registered Linux User #388732

  4. #4
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Yes cabhan it does make sense now...Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...