[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These options come into play when the compiler links object files into an executable output file. They are meaningless if the compiler is not doing a link step.
object-file-name
-c
-S
-E
-llibrary
It makes a difference where in the command you write this option; the linker searches processes libraries and object files in the order they are specified. Thus, `foo.o -lz bar.o' searches library `z' after file `foo.o' but before `bar.o'. If `bar.o' refers to functions in `z', those functions may not be loaded.
The linker searches a standard list of directories for the library, which is actually a file named `liblibrary.a'. The linker then uses this file as if it had been specified precisely by name.
The directories searched include several standard system directories plus any that you specify with `-L'.
Normally the files found this way are library files--archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an `-l' option and specifying a file name is that `-l' surrounds library with `lib' and `.a' and searches several directories.
-lobjc
-nostartfiles
-nodefaultlibs
-nostdlib
One of the standard libraries bypassed by `-nostdlib' and
`-nodefaultlibs' is `libgcc.a', a library of internal subroutines
that GCC uses to overcome shortcomings of particular machines, or special
needs for some languages.
(See section Interfacing to GCC Output, for more discussion of
`libgcc.a'.)
In most cases, you need `libgcc.a' even when you want to avoid
other standard libraries. In other words, when you specify `-nostdlib'
or `-nodefaultlibs' you should usually specify `-lgcc' as well.
This ensures that you have no unresolved references to internal GCC
library subroutines. (For example, `__main', used to ensure C++
constructors will be called; see section collect2
.)
-s
-static
-shared
-shared-libgcc
-static-libgcc
There are several situations in which an application should use the shared `libgcc' instead of the static version. The most common of these is when the application wishes to throw and catch exceptions across different shared libraries. In that case, each of the libraries as well as the application itself should use the shared `libgcc'.
Therefore, whenever you specify the `-shared' option, the GCC driver automatically adds `-shared-libgcc', unless you explicitly specify `-static-libgcc'. The G++ driver automatically adds `-shared-libgcc' when you build a main executable as well because for C++ programs that is typically the right thing to do. (Exception-handling will not work reliably otherwise.)
However, when linking a main executable written in C, you must explicitly say `-shared-libgcc' if you want to use the shared `libgcc'.
-symbolic
-Xlinker option
If you want to pass an option that takes an argument, you must use `-Xlinker' twice, once for the option and once for the argument. For example, to pass `-assert definitions', you must write `-Xlinker -assert -Xlinker definitions'. It does not work to write `-Xlinker "-assert definitions"', because this passes the entire string as a single argument, which is not what the linker expects.
-Wl\,option
-u symbol
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |