GCC找不到包含的头 [英] gcc Can't Find a Included Header

查看:115
本文介绍了GCC找不到包含的头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了一个名为标题 colors.h 来整理我的源$ C ​​$ C。标题是这样的:

I'm using a header called colors.h to organize my source code. The header is like this:

#define DEFAULT 0x07
#define BLACK 0
#define GRAY 7
#define BLUE 9
#define GREEN 10
#define CYAN 11
#define RED 12
#define MAGENTA 13
#define YELLOW 14

我把标题的主要来源$ C ​​$ C的同一目录下,名为 kernel.c ,以及包括像这样:

#include <colors.h>

但是,当我尝试编译,我得到这样的:

But when I try to compile, I'm getting this:

Ubuntu的@ EeePC的:〜/开发/测试$ gcc的-o kernel.o -c kernel.c -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs结果
  kernel.c:1:20:错误:colors.h:没有这样的文件或目录结果
  Ubuntu的@ EeePC的:〜/开发/测试$

ubuntu@eeepc:~/Development/Test$ gcc -o kernel.o -c kernel.c -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs
kernel.c:1:20: error: colors.h: No such file or directory
ubuntu@eeepc:~/Development/Test$

我能做些什么来解决这个?

What I can do to solve this?

推荐答案

使用引号:

#include "colors.h"

使用引号将查找在同一目录下,然后再在指定的include路径。
使用尖括号看起来只在包括路径。

Using quotes will look in the same directory first, and then in the specified include paths. Using angle brackets will look in the include paths only.

这篇关于GCC找不到包含的头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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