开发者_开发技巧I have all my project include files in a specific dir (called include
, in my project dir). When I include them in a cpp file, I need to
#include "include/somefile.h"
How can I make it so that I can do
#include <somefile.h>
?
Use the -I
flag of the compiler. Like:
~$ c++ -Wall -Werror -pedantic -I/home/user/include -c source_file.cpp
Using double quotes to include looks within the local working directory, while includes wrapped in angle brackets tell the linker/compiler to look in standard locations such as /usr/bin/ (on *nix platforms). You can tell it to look other places with the -I compiler directive (with gcc/g++ at least, IDEs like Visual Studio have their own mechanisms).
精彩评论