Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

gcc

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

like image 787
Bingo Avatar asked May 01 '11 06:05

Bingo


People also ask

How do I include multiple paths in GCC?

To specify multiple search path directories on the command line, the options -I and -L can be repeated. For example, the following command, $ gcc -I. -I/opt/gdbm-1.8.

How do I add a header in GCC?

GCC looks for headers requested with #include " file " first in the directory containing the current file, then in the directories as specified by -iquote options, 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.

How do you tell the compiler to look for header files in a different directory?

it's simple, use the "-B" option to add . h files' dir to search path. Show activity on this post. Headers included with #include <> will be searched in all default directories , but you can also add your own location in the search path with -I command line arg.

Do you need to include header files in GCC?

We no longer need to include the system header file 'stdio. h' in 'main.


1 Answers

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

like image 171
Chris Stratton Avatar answered Nov 10 '22 00:11

Chris Stratton