如何在GCC中指定默认包含目录 [英] How to specify default include directory in GCC

查看:358
本文介绍了如何在GCC中指定默认包含目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是GCC的新手,我想知道如何告诉编译器需要将几个包含目录指定为搜索.h文件的默认目录.我读到 -I dir 是完成此操作的关键,但是在生成文件时,我遇到了一些问题.例如:

I am new in GCC and I am wondering how to tell the compiler that several include directories need to be specified as default for searching .h files. I read that -I dir is the key to accomplish that but doing my makefiles I encounter some problems. For example:

include_dir = C:/Users/rmrd001/Documents/Make/GCC/first/mydir/
FLAGS = -I "$(include_dir)"

func2.o: func2.c func2.h
    gcc $(FLAGS) -c func2.c

我得到了错误:

make:***没有规则来创建目标'func2.c',这是'func2.o'所需要的.停止.

include_dir 不是工作目录.这是 working_directory/my_dir . 请帮忙.

The include_dir is not the working directory. It is working_directory/my_dir. Please help.

推荐答案

-I用于查找包含文件,而不用于查找主文件.您必须将显式路径传递到主文件.

-I is used for finding include files, but not for finding the main file. You have to pass an explicit path to the main file.

这篇关于如何在GCC中指定默认包含目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆