Why can't I access a header file at the environment path?

I added a path to the path environment variable,
but I cannot include the headers at that location via #include <file.h>

What am I doing wrong?

On linux stuff is just easier to set up...
Last edited on
Assuming you're using some version of Windows ...

I added a path to the path environment variable

path for what? your compiler?

but I cannot include the headers at that location via #include <file.h>

assuming further that your compiler's location has been added to the path you don't need to included headers at that location. Just include the headers in the source file and run it from cmd prompt as
g++ -o test test.cpp for example where test.exe will be the executable created out of test.cpp source file. But make sure you're in the test.cpp directory before you do the above code
What compiler and operating system are you using, and how are you trying to compile the code?

On Windows the compiler searches in the following way:
The preprocessor searches for include files in the following order:

1. In the same directory as the file that contains the #include statement.

2. In the directories of any previously opened include files in the reverse order in which they were opened. The search starts from the directory of the include file that was opened last and continues through the directory of the include file that was opened first.

3. Along the path specified by each /I compiler option.

4. Along the paths specified by the INCLUDE environment variable.

(from: http://stackoverflow.com/questions/9521243/where-does-visual-studios-compiler-search-for-includes )

But you really should be adding the directory to the project via the compiler options option. Or via the /I command line option.

Topic archived. No new replies allowed.