2

I'm writing a pretty long program with a complex folder structure in c++, using a simple Notepad++ editor and SDK7.1 compiler. I have created several files with some basic functions that I call into my main file using #include <filename.h>. When compiling I get the following error: filename: No such file or directory

I'd like to append the directory path so the compiler can find my .h files. I have found a lot of help on the issue using Visual Studio's built-in tools but nothing on actual coding syntax to achieve this.

I have already tried switching #include <filename.h> to #include "filename.h" and it did not change the error. The only thing that has worked so far is calling out #include <C:\....\filename.h> but this is not a desirable solution because I am #includeing many files at the beginning of my program. Please help! Thanks in advance

Ben
  • 21
  • 3
  • 1
    For your own headers it's `#include "filename.h"`, not `#include ` – Paul R Feb 09 '16 at 17:59
  • likely duplicate of http://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename – Cee McSharpface Feb 09 '16 at 18:01
  • I tried this simple change and it did not fix the problem. The only thing that did work so far has been explicitly typing out the complete path, which is not desirable since I am `#include`ing many different files and the folder structure is so complex. – Ben Feb 09 '16 at 18:06
  • Pass [/I flag](https://msdn.microsoft.com/en-us/library/73f9s62w(v=vs.100).aspx) to the compiler. – CristiFati Feb 09 '16 at 18:06
  • @CristiFati can you please be more specific? I'm a newbie so the more detail the better. Do I add a line similar to `/I C:\....\filepath` before I `#include` the problem files? I think I'm misunderstanding you because this does not work either. – Ben Feb 09 '16 at 18:15
  • No, when you compile your source files (the step that throws the error), you invoke the compiler(typically _cl.exe_), with a bunch of arguments (some of them is your _.c_ file). You just have to add `/IThePathToYourHFiles` (double quote the path if necessary) to that argument list. – CristiFati Feb 09 '16 at 18:20
  • Okay @CristiFati I think we are getting closer here, but I'm still having trouble. Can we try a more specific example? Let's say that `fileA.h` is in `C:\User\Desktop\ProjectFile\Files2Include`. Are you saying that the following should be added to the main file to add the new directory? `/I"C:\User\Desktop\ProjectFile\Files2Include";` followed by `#include ` ??? – Ben Feb 09 '16 at 18:29
  • I am just saying to add the folder where your _.h_ files reside. And that's the path to your include files.include them as '/I', each for folder... – CristiFati Feb 09 '16 at 23:48

0 Answers0