Directory Options See Options for Directory Search.-Bprefix -Idir-iplugindir=dir -iquotedir -Ldir -specs=file -I- --sysroot=dir --no-sysroot-suffix
Linker Options See Options for Linking.object-file-name -llibrary -nostartfiles -nodefaultlibs -nostdlib -pie -rdynamic -s -static -static-libgcc -static-libstdc++ -static-libasan -static-libtsan -static-liblsan -static-libubsan -shared -shared-libgcc -symbolic -T script -Wl,option -Xlinker option -u symbol
- Option Summary: Brief list of all options, without explanations.
- Overall Options: Controlling the kind of output: an executable, object files, assembler files, or preprocessed source.
- Invoking G++: Compiling C++ programs.
- C Dialect Options: Controlling the variant of C language compiled.
- C++ Dialect Options: Variations on C++.
- Objective-C and Objective-C++ Dialect Options: Variations on Objective-C and Objective-C++.
- Language Independent Options: Controlling how diagnostics should be formatted.
- Warning Options: How picky should the compiler be?
- Debugging Options: Symbol tables, measurements, and debugging dumps.
- Optimize Options: How much optimization?
- Preprocessor Options: Controlling header files and macro definitions. Also, getting dependency information for Make.
- Assembler Options: Passing options to the assembler.
- Link Options: Specifying libraries and so on.
- Directory Options: Where to find header files and libraries. Where to find the compiler executable files.
- Spec Files: How to pass switches to sub-processes.
- Target Options: Running a cross-compiler, or an old version of GCC.
- Submodel Options: Specifying minor hardware or convention variations, such as 68010 vs 68020.
- Code Gen Options: Specifying conventions for function calls, data layout and register usage.
- Environment Variables: Env vars that affect GCC.
- Precompiled Headers: Compiling a header once, and using it many times.
It makes a difference where in the command you write this option; the linker searches and 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.
If a standard system include directory, or a directory specified with -isystem, is also specified with -I, the -I option is ignored. The directory is still searched but as a system directory at its normal position in the system include chain. This is to ensure that GCC’s procedure to fix buggy system headers and the ordering for the
include_next directive are not inadvertently changed. If you really need to change the search order for system directories, use the -nostdinc and/or -isystem options.
By default, the object file name for a source file is made by replacing the suffix ‘.c’, ‘.i’, ‘.s’, etc., with ‘.o’.
Unrecognized input files, not requiring compilation or assembly, are ignored.
If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, its assembler file in source.s, a precompiled header file in source.suffix.gch, and all preprocessed C source on standard output.
=, then the
=will be replaced by the sysroot prefix; see –sysroot and -isysroot.
#ifexpressions. Note that many of the preprocessor’s warnings are on by default and have no options to control them.