如何在单个gcc命令中向搜索路径添加多个报头和库目录?

时间:2021-10-04 02:04:51

How to add multiple header include and library directories to the search path in a single gcc command?

如何在单个gcc命令中向搜索路径添加多个报头和库目录?

3 个解决方案

#1


72  

Use multiple -I flags for the include directories and multiple -L flags for the lib directories

对于包含目录使用多个-I标志,对于lib目录使用多个-L标志

#2


22  

You can set the C_INCLUDE_PATH environment variable.

可以设置C_INCLUDE_PATH环境变量。

export C_INCLUDE_PATH=.:/some/dir:/some/other/dir

as well as the LIBRARY_PATH environment variable.

以及LIBRARY_PATH环境变量。

#3


3  

On Linux you need to use -I before each directory that you want to add.

在Linux上,您需要在想要添加的每个目录之前使用-I。

Example:

例子:

user:/home/my_project$ gcc -g -Wall -I/usr/include/lib_Directory/ -I./include -c ./src/transcod.c

./ means the current directory where you are running the command, in this case my_project;

./表示正在运行命令的当前目录,在本例中为my_project;

#1


72  

Use multiple -I flags for the include directories and multiple -L flags for the lib directories

对于包含目录使用多个-I标志,对于lib目录使用多个-L标志

#2


22  

You can set the C_INCLUDE_PATH environment variable.

可以设置C_INCLUDE_PATH环境变量。

export C_INCLUDE_PATH=.:/some/dir:/some/other/dir

as well as the LIBRARY_PATH environment variable.

以及LIBRARY_PATH环境变量。

#3


3  

On Linux you need to use -I before each directory that you want to add.

在Linux上,您需要在想要添加的每个目录之前使用-I。

Example:

例子:

user:/home/my_project$ gcc -g -Wall -I/usr/include/lib_Directory/ -I./include -c ./src/transcod.c

./ means the current directory where you are running the command, in this case my_project;

./表示正在运行命令的当前目录,在本例中为my_project;