2009-06-10 96 views
36

我有一个样本文件下面的代码:如何在GCC搜索路径中包含头文件?

#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" 

然而,这个代码位于不同的文件夹中的/ home /我/开发/ Skia的范围内(包括核心/动画/图片/端口/ SVG /和更多。)

我该如何让GCC认识到这条道路?

+0

http://stackoverflow.com/questions/558803/how-to-add-a-default-include-path-for-gcc-in-linux – 2015-06-09 12:01:57

回答

55

尝试gcc -c -I/home/me/development/skia sample.c。见here

+1

很高兴在这里看到这个答案。另一点值得一提的是,当你有很多“.c”源文件时,有必要在命令行中指定它们中的每一个。你不能只做一个像-I的东西来指定所有源文件都在某个目录中。 – Nav 2011-09-06 06:20:09

16

-I指令做这项工作:

gcc -Icore -Ianimator -Iimages -Ianother_dir -Iyet_another_dir my_file.c