I have a source repository having A, B , C and D sub-repositories. Each A, B, C and D has its own "include" directory where compiler tries to look for header files. I want to include a header file from A into C. I tried copying absolute path but the header itself has some relative path includes which would work only in C directory, as they are not in include directory of B. What is a clean way to include a header file from some other directory in this case?
I am using g++ compiler.
答案 0 :(得分:0)
您需要告诉编译器在每个{A,B,C,D}/include
目录中搜索标头。然后,使用相对于任何包含目录的路径包含文件。
在linux上
然后您可以使用man
命令找到编译器的手册。本手册将介绍如何指定包含目录。
答案 1 :(得分:0)
使用GCC
使用-I
选项添加包含目录的路径:
g++ -IA/include -IB/include -IC/include -ID/include` -o myprogram myprogram.cpp