linux 编译,链接,动态链接库
2013-10-12 22:20
429 查看
#include <stdio.h>
When the include file is in brackets the preprocessor first searches in paths specified via the -I flag. Then it searches the standard include paths
(see the above link, and use the -v flag to test on your system).
#include "myFile.h"
When the include file is in quotes the preprocessor first searches in the current directory, then paths specified by -iquote, then -I paths,
then the standard paths.
-nostdinc can be used to prevent the preprocessor from searching the standard paths at all.
Environment
variables can also be used to add search paths.
When compiling if you use the -v flag you can see the search paths used.
Next: Once-Only Headers, Previous: Include
Operation, Up: Header Files
2.3 Search Path
GCC looks in several different places for headers. On a normal Unix system, if you do not instruct it otherwise, it will look for headers requested with#include <file
>in:
/usr/local/include libdir/gcc/target/version/include /usr/target/include /usr/include
For C++ programs, it will also look in libdir/../include/c++/version, first. In the above, target is the canonical name of the system GCC was
configured to compile code for; often but not always the same as the canonical name of the system it runs on. version is the version of GCC in use.
You can add to this list with the -Idir command line option. All the directories named by -I are searched, in left-to-right order, before the
default directories. The only exception is when dir is already searched by default. In this case, the option is ignored and the search order for system directories remains unchanged.
Duplicate directories are removed from the quote and bracket search chains before the two chains are merged to make the final search chain. Thus, it is possible for a directory to occur twice in the final search
chain if it was specified in both the quote and bracket chains.
You can prevent GCC from searching any of the default directories with the -nostdinc option. This is useful when you are compiling an operating system kernel or some other program that does not use
the standard C library facilities, or the standard C library itself. -I options are not ignored as described above when -nostdinc is in effect.
GCC looks for headers requested with
#include "file
"first in the directory containing the current file, then in the directories as specified by -iquoteoptions,
then in the same places it would have looked for a header requested with angle brackets. For example, if /usr/include/sys/stat.h contains
#include "types.h", GCC looks for types.h first in /usr/include/sys,
then in its usual search path.
‘#line’ (see Line Control) does not change GCC's idea of the directory containing the current file.
You may put -I- at any point in your list of -I options. This has two effects. First, directories appearing before the -I- in the list are searched only for headers requested
with quote marks. Directories after -I- are searched for all headers. Second, the directory containing the current file is not searched for anything, unless it happens to be one of the directories named by an -I switch. -I- is
deprecated, -iquote should be used instead.
-I. -I- is not the same as no -I options at all, and does not cause the same behavior for ‘<>’ includes that ‘""’ includes get with no special options. -I. searches
the compiler's current working directory for header files. That may or may not be the same as the directory containing the current file.
If you need to look for headers in a directory named -, write -I./-.
There are several more ways to adjust the header search path. They are generally less useful. See Invocation.
相关文章推荐
- linux下gcc编译 .c文件生成动态链接库 .so文件,并测试调用该链接库
- 【基础知识】linux c 编译链接运行、动态链接库
- 编译链接------Linux环境下c语言静态链接库和动态链接库创建和使用
- 编译链接------Linux环境下c语言静态链接库和动态链接库创建和使用
- 如何在Linux下用C/C++语言操作数据库sqlite3(很不错!设计编译链接等很多问题!)
- Linux GCC编译、gdb调试、makefile、动态链接库的创建
- linux下预处理、编译、汇编、链接及gdb调试
- 如何将arm-linux-gcc编译的动态链接helloworld在Android上运行
- C语言程序的编译、链接具体过程及Linux环境下的具体实例
- linux 安装库 编译提示-lcrypto 无法链接,缺少 crypto 库
- Linux编译的时候由于链接库出现的各种问题
- 关于Linux下编译和使用动态链接库静态链接库
- Linux下预处理,编译,汇编,链接过程及gdb的使用
- linux编译与链接的知识
- Linux 静态、动态链接库编译
- Linux Makefile自动编译和链接使用的环境
- Linux 动态链接库与静态链接库---隐式链接
- Linux下GCC 编译时为什么要指定链接库?如何指定链接库 ?
- 【Linux/C】程序的编译和链接--例子
- Linux下编译使用自己的动态链接库-详解