- COnly the target file (. o) is generated and is not connected.
% gcc-c main.c
% g++-C reciprocal.cpp
- I.You can specify a directory for header files
% g++-c-i. /include Reciprocal.cpp
- DSet macro definition
% g++-c-d ndebug reciprocal.cpp% g++-c-d ndebug=3 reciprocal.cpp
- oOptimization level, the default optimization level is 2
% g++-c-o2 reciprocal.cpp
- oconnecting programs, generating executable
How to specify the default header file path for GCC
There are a large number of environment variables that can be set to affect how GCC compiles the program. You can also use the appropriate command-line options to control the variables. Some environment variables are set in the table of directory names. These names are used in the same format as the PATH environment variable. Special character path_separator (defined when the compiler is installed) is used between directory names. In a UNIX system, the separator is a colon, and a semicolon is in the Windows system.C_include_pathUse this environment variable when compiling a C program. The environment variable specifies one or more list of directory names, looking for header files, as if specifying on the command line-isystemOptions are the same. All directories specified by-isystem are first looked up. See also CPath, Cplus_include_path and Objc_include_path.Compiler_pathThe environment variable specifies one or more list of directory names, and if a gcc_exec_prefix locator is not specified, the compiler finds its subroutines here. See also Library_path, Gcc_exec_prefix, and-B command-line options.CPathUse this environment variable when compiling C, C + +, and objective-c programs. The environment variable specifies one or more list of directory names, looking for header files as if the-l option is specified on the command line. All directories specified by-L are first looked up. See also C_include_path, Cplus_include_path and Objc_include_pathCplus_include_pathUse this environment variable when compiling a C + + program. The environment variable specifies one or more list of directory names, looking for header files as if you were specifying the ISYSTEM option on the command line. All directories specified by-isystem are first looked up. See also CPath, C_include_path and Objc_include_path.Dependencies_outputSetting the environment variable for the file name allows the preprocessor to write the file based on the makefile rule of the dependency relationship. The system header file name will not be included. If the environment variable is set to Single-name, it is considered a file name, and the dependency rule name comes from the source file name. If there are two names in the definition, the second name is the target name used as the dependency rule. The result of setting the environment variable is the same as the combination of the command line Options MM,-MF, and-MT. See Sunpro_dependencies, too.Gcc_exec_prefixIf the environment variable is defined, it is prefixed with all the subroutine names that the compiler executes. For example, if you set a variable to Testver instead of finding as, the assembler first looks under the name Testveras. If it is not found here, the compiler continues to find it based on its normal name. You can use a slash in the prefix name to indicate the path name.Gcc_exec_prefixThe default setting is prefix/lib/gcc-lib/, where the prefix is the name specified by the Configure script when the compiler is installed. The prefix is also used to locate standard connector files, which are included as part of an executable program. If you use the-B command-line option, this setting is overridden. See also Compiler_path.LANGThis environment variable is used to indicate the character set used by the compiler to create wide-character text, string literals, and comments. Define LANG as C-jis, which indicates that the preprocessor interprets multibyte characters according to JIS (Japanese industry standard) characters. C-sjis can be used to indicate shift-jis characters and c-eucjp to indicate Japanese EUC. If LANG is not defined, or is defined as unrecognized, the function Mblen () is used to determine the width of the character, and MBTOWC () is used to convert multibyte sequences to wide characters.Lc_allIf set, the value of the environment variable overrides all settings for Lc_messages and Lc_ctype.lc_ctypeThe environment variable indicates the character classification of multibyte characters defined in the reference string. Used primarily to determine the character bounds of a string, which requires quotation marks or escape characters that can be incorrectly interpreted as the end of a string or a special string. For Australian 中文版, you can set it to En_au, and to Mexican Spanish, you can set it to es_mx. If the variable is not set, the default is the value of the lang variable, or if Lang is not set, use C English behavior. See also Lc_all.lc_messagesThe environment variable indicates what language the compiler uses to emit diagnostic messages. For Australian 中文版, can be set to En_au, to Mexicanspanish, can be set to ES_MX. If the variable is not set, the default value for the lang variable is used, or if Lang is not set, then the C English behavior is used. See also Lc_all.Ld_library_pathThe environment variable does not affect the compiler, but it can affect when the program is running. variable specifies a list of directories that the program finds to locate the shared library. The executing program must set this variable only if the shared library is not found in the directory of the compiled program.Ld_run_pathThe environment variable does not affect the compiler, but it can affect when the program is running. The variable indicates the name of the file at run time, and the running program can get its symbolic name and address. The address is not loaded again, so it is possible for the symbol to refer to an absolute address in another file. This is exactly the same as the LD tool using the-r option.Library_pathThe environment variable can be set to one or more directory name lists, and the connector searches the directory for special connection program files and libraries with names specified by the-L (letter L) command-line option. The directory specified by the-l command-line option is first looked up before the environment variable. See also Compiler_path.Objc_include_pathUse the environment variable when compiling the OBJECTIVE-C program. The list of one or more directory names is specified by the environment variable to find the header file as if you were specifying the-ISYSTEM option on the command line. All directories specified by the-isystem option are first searched. See also CPath, Cplus_include_path and C_include_path.Sunpro_outputSetting this environment variable for a file name will cause the preprocessor to write to the file based on the makefile rule of the dependency relationship. Will contain the system header file name. If the environment variable is set to a single name, it will be treated as a filename, and the name in the dependency rule will be obtained from the name of the source file. If there are two names in the definition, the second name is the target name in the dependency rule. The result of setting this environment variable is the same as using Parameters-M,-MF, and-MT on the command line. See Dependencies_output.TmpdirThis variable contains the pathname of the directory where the compiler holds temporary working files. These files are usually deleted at the end of the compilation process. An example of such a file is a file that is output by the preprocessor and entered to the compiled program.Linux System header file and library file search path
* * * #include header file, link database, System definition, total of the following sources specify GCC go there. The environment variable (at compile time) that was specified at compile time (in the ~gcc/gcc/collect2.c:locatelib () written in specs (for the RPM package) was later set (compiled) with the GCC environment variable (-d-i-L) ld.so (this is the run Time) header file
How does GCC find the required headers at compile time: header file search starts with-I and finds GCC's environment variable C_include_path,cplus_include_path,objc_include_path to find the default directory:/ Usr/include/usr/local/include/usr/lib/gcc-lib/i386-linux/2.95.2/include/usr/lib/gcc-lib/i386-linux/2.95.2/.. /.. /.. /.. /include/g++-3/usr/lib/gcc-lib/i386-linux/2.95.2/.. /.. /.. /.. /i386-linux/include Library file But if there is a given prefix when GCC is installed, then it is/usr/include prefix/include prefix/xxx-xxx-xxx-gnulibc/ Include Prefix/lib/gcc-lib/xxxx-xxx-xxx-gnulibc/2.8.1/include library files
The options for the Cos () function library are more-LM compile: GCC will find the environment variable of GCC to find Library_path and then find the default directory/lib/usr/lib/usr/local/lib This is the original compile GCC written in the program Search path for runtime dynamic libraries
1 Specify a dynamic library search path in the configuration file/etc/ld.so.conf
2 Specify the dynamic library search path through the environment variable Ld_library_path (when multiple dynamic library search paths are specified through the environment variable, the paths are separated by a colon ":")
3 Specifies the dynamic library search path for the program when compiling the target code (you can also specify the program's dynamic Library search path when compiling the target code). This is specified by the parameter "-wl,-rpath," of GCC. When multiple dynamic library search paths are specified, the paths are separated by a colon ":".
4 Default dynamic Library search path/lib
5 Default dynamic Library search path/usr/lib
The sequence of search paths for dynamic libraries is:
1 The dynamic library search path specified when the target code is compiled;
2 environment variable Ld_library_path the specified dynamic library search path;
3 The dynamic library search path specified in the configuration file/etc/ld.so.conf;
4 The default dynamic library search path/lib;
5 The default dynamic library search path/usr/lib.