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 ...
- 02-28-2008 #1
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?
- 02-28-2008 #2Linux Newbie
- Join Date
- Nov 2007
- Location
- Planet Earth
- Posts
- 152
Setup the correct environmet variable: Environment Variables - Using the GNU Compiler Collection (GCC)
HugoEOF
- 02-28-2008 #3
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
- 02-28-2008 #4
Yes cabhan it does make sense now...Thanks


Reply With Quote