[ fromfile: qmake.xml id: findingheaders ]
The three ways to #include
a library header file are
#include <headerFile> #include "headerFile" #include "path/to/headerFile"
The angle brackets (<>
) indicate that the preprocessor must look (sequentially) in the directories listed in the include path for the file.
A quoted filename indicates that the preprocessor should look for headerFile in the including file's directory first. A quoted path indicates that the preprocessor should check the path directory first. The path information can be absolute or relative (to the including file's directory). If no file is found at the specified location, the directories listed in the include path are searched for headerFile.
If versions of the file exist in more than one directory in the include path, the search stops as soon as the first occurrence of the file has been found. If the file is not found in any of the directories of the search path, then the compiler reports an error.
When the compiler was installed it was told where to find the header files in the C++ Standard Library.
For other libraries, you can expand the search path by adding the switch -I/path/to/headerfile
to the invocation of the compiler.
If you use an IDE, there will be a Project->Settings->Preprocessor
, or
Project->Options->Libraries
configuration menu that lets you specify additional include directories, which get passed as -I
switches to the compiler at build time.
With qmake
, as you will soon see, you can add INCLUDEPATH += dirName
lines to the project file.
These directories end up in the generated Makefile as INCPATH
macros, which then get passed on to the compiler/preprocessor at build time.
qmake -r | |
---|---|
Some project files are |
Tip | |
---|---|
In general, it is a good idea to |
For more information about the preprocessor and how it is used, see Section C.2.
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |