如何包括自定义.h文件在/ usr / include目录 [英] How to include custom .h files in /usr/include

查看:812
本文介绍了如何包括自定义.h文件在/ usr / include目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在/ usr / include目录,但在目录(/ usr / include目录/ itsmag1c)放置一些自定义的.h文件,我试图将它们纳入我的C文件。我猜是因为我用

I have some custom .h files placed under /usr/include, but in a directory (/usr/include/itsmag1c), and I'm trying to include them in my C file. I'm guessing that because I use

#include "filename.h";

在同一目录下的文件,我会用尖括号用于包括像math.h中或stdio.h中的文件。我是正确的猜测,我会用尖括号的包括我的自定义头文件?如果是这样,我的程序不会编译,我得到了包括文件无法找到的错误。可有人请指向我,我怎么会包含这些文件,或者这将是最好让他们在同一目录作为我的计划?

for files in the same directory, and I would use angle brackets for including a file like math.h or stdio.h. Am I right in guessing that I would use the angle brackets for including my custom header files? If so, my program wont compile, I get the error that the included files cannot be found. Can someone please point to me how I would include these files, or would it be best to have them in the same directory as my program?

推荐答案

两种选择:


  1. 使用的#include< itsmagic1c / filename.h>

使用的#include< filename.h> 和以前一样,但添加 -I 开关。

Use #include <filename.h> as before but add a -I switch.

升压等使用方法1(效果很好如果已经安装在系统中的位置提升,因为你会在一个合理的标准Linux主机,并合理的方案管理)。

Boost etc use method 1. (which works well provided you have Boost installed in system locations as you would on a reasonably standard Linux box with reasonable package management).

方法2是好的太多,但构建系统​​,Makefile文件等更多的工作。

Method 2. is fine too, but more work on the build system, Makefiles, etc.

这篇关于如何包括自定义.h文件在/ usr / include目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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