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

CGcc

C Problem Overview


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

C Solutions


Solution 1 - C

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

Solution 2 - C

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.

Solution 3 - C

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;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBingoView Question on Stackoverflow
Solution 1 - CChris StrattonView Answer on Stackoverflow
Solution 2 - CBrian RoachView Answer on Stackoverflow
Solution 3 - CJeff PalView Answer on Stackoverflow