views:

857

answers:

2

I am using visual studio 2008 and I need to use certain header files from another project. I have tried to do add the path in "Additional Include Directories" in C/C++ General properties pane but my project still puts out the same errors (fatal error C1083: Cannot open include file: 'tools/rcobject.h'.

All the other cpp and header files I am using I added as existing files from another directory and for some headers it puts out an error and for others it doesn't. There was no change in errors after adding additional include directories.

Can someone help me, I am stuck as I need to Debug...

A: 

In the "Additional Include "Directories", did you put the path to the "tools" directory, or the path to the directory that includes the "tools" directory? It needs to be the latter.

How the preprocessor works to resolve #include directives, is to take the path specified in the #include and then append it to each of the paths specified in the "additional include paths" (plus some other places specific for the project. So, you need to make sure that the path specified in the "additiional include paths" PLUS the path you gave to the #include exactly matches the path to the file you are trying to include.

For example, suppose you have the following file you want to include:

c:\blah\bletch\foo\bar.txt

Then you did this:

#include "bar.txt"

Then you would need to make sure that "c:\blah\bletch\foo" was in the "additional include paths".

Or if you had done this:

#include "foo\bar.txt"

Then you would need to make sure that "c:\blah\bletch" was in the "additional include paths".

1800 INFORMATION
my header is in the "D:\tool\src\cpp" directory and this is the directory I added in the "Additional Include "Directories". I also tried putting "rcobject.h" and not "tools/rcobject.h" but it didn't work. I have 11 other such header files I need to use.
He said he used the C/C++ General properties pane, does that contain settings for the tools directory? I think you're thinking of the global VS directory settings, but maybe I'm wrong, I don't have access to VS2008 from where I'm typing this. :)Regards,Sebastiaan
Sebastiaan Megens
I've added some more detail
1800 INFORMATION
ok, thanks, that did it :)
A: 

Enable the build log (I don't know from the top of my head where it is, shouldn't be too hard to find) and see if the paths you specify appear in the compiler command line. If not you're probably doing something wrong. Using additional include directories should just work. Just make sure you're using the right directory separator and you fill them in under the correct configuration (Release/Debug).

Regards,

Sebastiaan

Sebastiaan Megens