Question

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

Was it helpful?

Solution

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top