Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include *project root* headers compiling with GCC C++ compiler?

Tags:

gcc

g++

build

How to include headers located in project root compiling with GCC C++ compiler?
I want to tell GCC compiler to search for some header files in project root.
I do NOT want to make changes in code and use relative paths in #include directives - e.g. #include "../../myheader.h"
I compile source code I do not own and I do not want to maintain own version.
I do NOT want to specify absolute include path e.g. g++ -c -IC:\root_project_folder .. for obvious reasons.
I have tried: g++ -c -I .., g++ -c -I/ .. and g++ -c -I"/" .. but it does not work.

Please advise.

root_project_folder
|--myheader.h
  |--src_folder
    |-prog.cpp
like image 835
T. Jastrzębski Avatar asked Feb 07 '26 20:02

T. Jastrzębski


1 Answers

The symbol for the current directory is ..

You're looking for -I.

like image 55
HolyBlackCat Avatar answered Feb 12 '26 16:02

HolyBlackCat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!