How to tell g++ compiler where to search for include files?

后端 未结 4 1731
难免孤独
难免孤独 2020-12-01 23:38

In a \"working directory\" I have a lot of *.cpp and *.h files that #include each other and files from subdirectories.

For example:

#inc         


        
4条回答
  •  不思量自难忘°
    2020-12-02 00:03

    Every C/C++ compiler (g++, gcc, MinGW, clang, e.t.c.) has a folder called "include" in it's root path where it automatically looks for header files. If you use MinGW, it would be in, for example: "C:\MinGW\include". Just save your header to the include folder like this: C:\MinGW\include\header1.h or C:\MinGW\include\LibGUI\Window.h

提交回复
热议问题