2

I was trying to separate my header files (.h) from my (.cpp) implementation by storing them in two different source folders. However, Eclipse then tells the compiler to look for the .h file in the same folder as the .cpp file. This causes the compiler to stop as it can't find the specified file. Is there any way to create such folders in Eclipse and get around this issue?

In visual studio there is separate folder for header files so can we make a separate folder for header files in Eclipse CDT too?

Pete Houston
  • 14,931
  • 6
  • 47
  • 60
  • Add the header folder by selecting your project, right-clicking to get the context menu, then: `Properties->C/C++ General->Preprocessor, Include Paths, Macros, etc...` On that window select the `Entries` tab and then `C++` and then `CDT User Settings Entries`. Then `Add` and add your `include` folder there. – Galik Jan 04 '15 at 07:11
  • @Galik: Thanks friend, now i added header folder which contain header.h file, And added in main.cpp file, but it says "fatal error: header.h: no such file or directory " screenshot: http://prntscr.com/5oge3s – Akshay Birajdar Jan 04 '15 at 18:13
  • 2
    Ok forget that last comment. I never use managed builds and it doesn't work the same way so, you need to go to a slightly different window to add the folder: Right Click select the project. `Properties->C/C++ General->Paths and Symbols`, select `Includes` tab, then `GNU C++` then `Add...` – Galik Jan 04 '15 at 18:54
  • @Galik: Thanks friend , it worked :D with both symbols "" and <> – Akshay Birajdar Jan 05 '15 at 05:19
  • Duplication of https://stackoverflow.com/questions/13298550/eclipse-c-including-header-file-from-my-source-folder – hamavreg Jun 18 '17 at 20:13

0 Answers0