009
06.08.2003, 14:53 Uhr
Pablo
Supertux (Operator)
|
Ich hab folgende Information gefunden:
Zitat: |
Files with other suffixes are passed to the linker. Common cases include:
.o Object file .a Archive file
Linking is always the last stage unless you use one of the -c, -S, or -E options to avoid it (or unless compilation errors stop the whole process). For the link stage, all .o files corresponding to source files, -l libraries, unrecognized filenames (including named .o object files and .a archives) are passed to the linker in command-line order.
Linker Options -llibrary -nostartfiles -nostdlib -static -shared -symbolic -Xlinker option -Wl,option -u symbol
LINKER OPTIONS 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 A file name that does not end in a special recognized suffix is considered to name an object file or library. (Object files are distinguished from libraries by the linker according to the file contents.) If GCC does a link step, these object files are used as input to the linker.
-llibrary Use the library named library when linking.
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 sym bols that have so far been referenced but not defined. However, if the linker finds an ordi nary object file rather than a library, the object file 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 You need this special case of the -l option in order to link an Objective C program.
-nostartfiles Do not use the standard system startup files when linking. The standard libraries are used normally. -nostdlib Don't use the standard system libraries and startup files when linking. Only the files you specify will be passed to the linker.
-static On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has no effect.
-shared Produce a shared object which can then be linked with other objects to form an executable. On ly a few systems support this option.
-symbolic Bind references to global symbols when building a shared object. Warn about any unresolved references (unless overridden by the link editor option `-Xlinker -z -Xlinker defs'). Only a few systems support this option.
-Xlinker option Pass option as an option to the linker. You can use this to supply system-specific linker op tions which GNU CC does not know how to recognize.
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 Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas. -u symbol Pretend the symbol symbol is undefined, to force linking of library modules to define it. You can use `-u' multiple times with different symbols to force loading of additional library mod ules. DIRECTORY OPTIONS These options specify directories to search for header files, for libraries and for parts of the com piler:
-Idir Append directory dir to the list of directories searched for include files.
-I- Any directories you specify with `-I' options before the `-I-' option are searched only for the case of `#include "file"'; they are not searched for `#include <file>'.
If additional directories are specified with `-I' options after the `-I-', these directories are searched for all `#include' directives. (Ordinarily all `-I' directories are used this way.)
In addition, the `-I-' option inhibits the use of the current directory (where the current in put file came from) as the first search directory for `#include "file"'. There is no way to override this effect of `-I-'. With `-I.' you can specify searching the directory which was current when the compiler was invoked. That is not exactly the same as what the preprocessor does by default, but it is often satisfactory.
`-I-' does not inhibit the use of the standard system directories for header files. Thus, `-I-' and `-nostdinc' are independent.
-Ldir Add directory dir to the list of directories to be searched for `-l'.
-Bprefix This option specifies where to find the executables, libraries and data files of the compiler itself.
The compiler driver program runs one or more of the subprograms `cpp', `cc1' (or, for C++, `cc1plus'), `as' and `ld'. It tries prefix as a prefix for each program it tries to run, both with and without `machine/version/'. For each subprogram to be run, the compiler driver first tries the `-B' prefix, if any. If that name is not found, or if `-B' was not specified, the driver tries two standard prefixes, which are `/usr/lib/gcc/' and `/usr/local/lib/gcc-lib/'. If neither of those results in a file name that is found, the compiler driver searches for the unmodified program name, using the di rectories specified in your `PATH' environment variable.
The run-time support file `libgcc.a' is also searched for using the `-B' prefix, if needed. If it is not found there, the two standard prefixes above are tried, and that is all. The file is left out of the link if it is not found by those means. Most of the time, on most machines, `libgcc.a' is not actually necessary.
You can get a similar result from the environment variable GCC_EXEC_PREFIX; if it is defined, its value is used as a prefix in the same way. If both the `-B' option and the GCC_EXEC_PREFIX variable are present, the `-B' option is used first and the environment variable value second.
|
Ein bisschen lang, aber seht nützlich, vor allem, weil es weitere Infos zu -l und -L gibt. Vielleicht hast du die Header Dateien dieser Librerien falsch eingebunden. Meisten macht macht
Code: |
#include <path_of_library/lib_header.h>
|
und deshalb benutzt man auch -L, damit die Verzeichnisse auch gefunden werden. -- A! Elbereth Gilthoniel! silivren penna míriel o menel aglar elenath, Gilthoniel, A! Elbereth! |