Reputation: 31
I'm returning to the land of C++ from many years wandering the .NET wilderness and I'm finding that I've forgotten scary amounts of knowledge...
I have several VC++ 2010 projects (ProjA, ProjB, etc.) in a solution (Sol). Each project has a link to common header file (Header.h) linked from the Sol directory level to ProjX level. Try as I might the project refuses to compile, with and without "" and <>, various relative and absolute paths to 'additional includes', etc. if instead I copy the header file to the project directory all is well.
What gives? I obviously don't want to copy the file as that defeats the purpose of it being common.
Upvotes: 0
Views: 221
Reputation: 31
Thanks for the answers; very quick!
I've found the answer. The include file was being included from within a .RC resource file and those have their own additional include paths :(
Updated that and it all compiled nicely.
Thanks!
Upvotes: 3
Reputation: 9801
If my memory does not trick me, you have to add the directory to the list of include directories in the Project's Properties. All inclusion, execution and such happen relative to the project's directory. (The directory with the .prj file). My solution would be to make a project "SolCommonUtils" or something, and add it as a dependency. (This also triggers recompilation correctly.) I am not sure if the include gets added automagically, or you have to add it by hand.
In general though, add a bit more information to your questions. What error do you get? A simple example with the directory structure would help see the problem.
Upvotes: 1
Reputation: 2022
Are you sure you've tried the proper relative and absolute paths? Because if the file exists, and the path is correct, there is no way for the compiler to not find the file*. The fact that copying next to the project works shows that there must be some error in one or more include paths.
Did you maybe mix VisualStudio variables like $(SolutionDir)
and somewhere got the wrong one?
*Edit: Ok one way there is: If the user account VisualStudio is running under does not have access priviledges to it.
Upvotes: 0