简体   繁体   中英

'Additional include directories' in visual studio 2010 doesn't work

I am banging my head on this one for a while so I figure I will post. I have two library projects where Project2 uses/references Project1 in the following directory structure.

c:\code\Library\Project1
c:\code\Library\Project2

Both are library projects. I have included the path in Project2 at Properties>Configuration Properties>C/C++>General>'Additonal Include Directories'. It reads ..\\Project1; %(AdditionalIncludeDirectories) ..\\Project1; %(AdditionalIncludeDirectories)

Now there is a file in Project2 which #includes file that is present in project1 folder. Inspite of having included the path as above it still comes up with an error:

1>c:\code\Library\Project2\MyTestDlg.cpp(6): fatal error C1083: Cannot open include file: 'GraphCtrl.h': No such file or directory

The weird thing is that similar setting works if I don't change the original project names. The projects are originally in folder where they link fine.

c:\code\Library\Project1 1.0.0
c:\code\Library\Project2 1.0.0

What I am doing is removing the last version names from the project folders (and relink them together again) but this has become a nightmare! Any suggestions?

ps I did research on this quite a bit and it seems like has to do with length of the directories but I think I am well with in limits. The fact that previously longer folder names work and short doesn't, it shows lengths are not the issue.

Addon:

The following is the actual error I am getting with actual file names: One of the problem is that somehow it still references the old library with full name GraphCtrlLib 1.0.0.0 even though I have completely removed it and can't find any more reference of it. I this it probably is not related to this error though.

1>Build started 12/11/2012 5:16:02 PM.
1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.Targets(1200,9): warning : The referenced project '..\Graph\Graph.vcxproj' does not exist.
1>InitializeBuildStatus:
1>  Touching "Debug\ViewerLib.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>  OpenViewerDlg.cpp
1>c:\code\libraries\viewerlib\viewerdlg.cpp(6): fatal error C1083: Cannot open include file: 'GraphCtrl.h': No such file or directory

Finally fixed the problem. I opened the .vcxproj file in notepad and changed all reference of old path to new path and saved it. That fixed the problem.

It was caused by the fact that the project file was read only and VC2010 was not updating it properly. I kept making the changes in project properties and I could tell by reading back that they are as I wanted them but when I closed the project and load it back, it was back to what was before change. So the changes were never getting applied. VS2010 didn't tell me that it can't save or apply the changes but would accept them and never apply them!

I realize it's an old topic, but thought I'd add my solution in case future searchers have the same specific scenario.

In my case the additional include directory was defined as a User Macro in a Property Page (accessed via View, Property Manager, then right click on the project, Properties). But although the value was updated there, the property page was not actually saved (even though the C++, Command Line property showed the correct path (!)). Had to check out the .props file from source control and save it, then rebuild - finally the include files in that directory are found.

Adding this answer, just in case someone else needs it. I had the same problem in VS 2015.

I solved it by editing the .vcxproj file.

In it I search for "path"

Then add your include directory path to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM