如何在gcc中编译具有头文件的C程序? [英] How to compile a C program in gcc which has header files?

查看:875
本文介绍了如何在gcc中编译具有头文件的C程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用的命令是:


$ b我想在gcc中编译一个包含我的2个头文件的C程序。 $ b


gcc UDP_Receive.c -o UDP_Receive -lm


来编译它,但我得到一个错误,指出UDP_Data.h:没有这样的文件或目录



如何告诉编译器包含这些头文件?



头文件:


#includeUDP_Data.h



#includeCrypt.h

谢谢,
Ritesh

解决方案使用 -Idirectory 添加包含路径,或使你的 #include 语句使用相对路径。

编辑:
另请注意, #include 文件名在许多平台上都区分大小写。

EDIT2:
使用 #includeUDP_Data.h不是#包括< UDP_Data.h>


I want to compile a C program in gcc which has my 2 header files.

I am using the command:

gcc UDP_Receive.c -o UDP_Receive -lm

to compile it but I get an error stating "UDP_Data.h: No such file or directory"

How can I tell the compiler to include these header files?

Header Files:

#include "UDP_Data.h"

#include "Crypt.h"

Thanks, Ritesh

解决方案

Use -Idirectory to add include paths, or make your #include statement use relative paths.

EDIT: Also be aware that #include filenames are case sensitive on many platforms.

EDIT2: Use #include "UDP_Data.h" not #include <UDP_Data.h>

这篇关于如何在gcc中编译具有头文件的C程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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