Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include header files in GCC search path?

Tags:

c++

gcc

header

I have the following code in a sample file:

#include "SkCanvas.h" #include "SkDevice.h" #include "SkGLCanvas.h" #include "SkGraphics.h" #include "SkImageEncoder.h" #include "SkPaint.h" #include "SkPicture.h" #include "SkStream.h" #include "SkWindow.h" 

However, this code is located in various folders within /home/me/development/skia (which includes core/ animator/ images/ ports/ svg/ and a lot more.)

How can I make GCC recognize this path?

like image 437
Mark Avatar asked Jun 10 '09 00:06

Mark


People also ask

Do you need to include header files in GCC?

The declaration is used to ensure that the types of the arguments and return value match up correctly between the function call and the function definition. We no longer need to include the system header file 'stdio. h' in 'main.

Which option of GCC adds include directory of header files?

gcc -I adds include directory of header files.

Where does C search for header files?

The angle brackets (<>) cause the preprocessor to search for the header file in the standard place for header files on your system, usually the /usr/include directory.

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.


2 Answers

Try gcc -c -I/home/me/development/skia sample.c.

like image 92
Tim Gilbert Avatar answered Sep 20 '22 16:09

Tim Gilbert


The -I directive does the job:

gcc -Icore -Ianimator -Iimages -Ianother_dir -Iyet_another_dir my_file.c  
like image 35
Reginaldo Avatar answered Sep 22 '22 16:09

Reginaldo