C++ – using header files from another project (directory)

cheader-filesvisual-studio-2008

I am using Visual Studio 2008, and I need to use certain header files from another project. I have tried to 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…

Best Answer

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 Directories" (and some other places specific for the project). So, you need to make sure that the path specified in the "Additional Include Directories" 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 Directories".

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 Directories".

Related Topic