Vamsi Krishna B
Vamsi Krishna B

Reputation: 11490

g++ compile using custom header file

I want to use a header file, its included as #include <custom.h>

how can I compile it by using the custom.h header file ?

I tried -I /path/to/custom.h , but its giving me error that its not a directory..

Upvotes: 1

Views: 4572

Answers (2)

Roger Pate
Roger Pate

Reputation:

-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":

-I dir

Add the directory dir to the list of directories to be searched for header files. Directories named by -I are searched before the standard system include directories. 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. If dir begins with "=", then the "=" will be replaced by the sysroot prefix; see --sysroot and -isysroot.

Upvotes: 5

log0
log0

Reputation: 10917

Indeed /path/to/custom.h is not a directory but a file.

-I/path/to/custom/

Upvotes: 1

Related Questions