简体   繁体   English

g ++使用自定义头文件进行编译

[英]g++ compile using custom header file

I want to use a header file, its included as #include <custom.h> 我想使用头文件,其包含为#include <custom.h>

how can I compile it by using the custom.h header file ? 如何使用custom.h头文件进行编译?

I tried -I /path/to/custom.h , but its giving me error that its not a directory.. 我试过-I /path/to/custom.h ,但它给我的错误是它不是目录。

-I /path/to

This will enable all headers in that directory to be found. 这将使该目录中的所有标头都可以找到。

In man gcc, search (using / in your pager) for "-I dir": 在man gcc中,搜索(使用/在您的寻呼机中)“-I dir”:

-I dir 我目录

Add the directory dir to the list of directories to be searched for header files. 将目录dir添加到要搜索头文件的目录列表中。 Directories named by -I are searched before the standard system include directories. 在标准系统包含目录之前,将搜索-I命名的目录。 If the directory dir is a standard system include directory, the option is ignored to ensure that the default search order for system directories and the special treatment of system headers are not defeated. 如果目录dir是标准的系统包含目录,则忽略该选项以确保不会破坏系统目录的默认搜索顺序和系统标头的特殊处理。 If dir begins with "=", then the "=" will be replaced by the sysroot prefix; 如果dir以“ =”开头,则“ =”将被sysroot前缀替换; see --sysroot and -isysroot. 请参见--sysroot和-isysroot。

实际上, /path/to/custom.h不是目录,而是文件。

-I/path/to/custom/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM