84

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

3 Answers 3

133

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

Sign up to request clarification or add additional context in comments.

1 Comment

Does using -I/path/to/dir/ include all the header files in the sub directories present in /path/to/dir/ also?
48

You can set the C_INCLUDE_PATH environment variable.

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

as well as the LIBRARY_PATH environment variable.

1 Comment

This answer is pure gold!
25

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

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;

1 Comment

That's an aspect of the compiler, not the operating system

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.