Search code examples
c++netbeanscygwin

No such file (header file) error


I want to include a header file. I am working in a C++ environment, (C++11, Windows OS, Netbeans 7.3.1 IDE, Cygwin_4.x tool collection). I do not know how I setup the environment/IDE (I did it 6 months ago). I do not understand the fundamentals of the C++ build process or Cygwin related issues either, so I might have to fill in the gaps with some other references/documentation (on what specifically, I'm not sure).

My ultimate objective is to be able to include header files using a syntax that does not require the full file path. I want to write something terse, like:

#include "src\stuff\blah.h"  //or even better:  #include "blah.h"

The only way I can get my program to compile at all is by using the full file path, like this:

#include "C:\NetBeansProjects\Project1\src\stuff\blah.h"

And, I can only compile once using the full path. If I try to rebuild, it will bomb with the *** multiple target patterns. Stop. error. There are workarounds for this error; those being either 1) deleting the build and dist folders between each rebuild (yikes?), or 2) following this 16 step setup process.

I do not want to follow either of those workarounds because they do not appear to deliver what I want. How can I setup my environment to achieve what I want...of being able to include header files without using full paths?


Solution

  • Thanks to DanielKO for this answer.

    In my case, I was able to include with the syntax:

    #include "../stuff/blah.h"
    

    I did not have to configure anything under the "Code Assistance" section for the C++ compiler.

    All of my code is under "src" as the parent directory in my NetBeans project. It seems that the full path of the file is not required, and the only directory that must be referenced is the lowest level subdirectory (in my case, "stuff").