I am using the calcOne project of VS2015 today, and changed the project from the Debug version to the Release version. When compiling, an error "Cannot open the include file: "addFunc.h": No such file or directory" pops up, as shown in Figure (1):
However, changing the project from the Release version back to the Debug version compiles successfully. Therefore, it is judged that the compilation environments of the Release and Debug versions are different.
The reason for this problem is that the Release version does not configure the corresponding header file path.
Solution: Right-click "Project" --> Properties --> Select Release version --> C/C++ --> General -- "Additional include directory, add the corresponding header file.
Method 1 Modify through the property page
This example is the header file path of addFunc.h: ..\myCommon should be added to the C/C++ accessories include directory, as shown in Figure (2):
When compiling, select the Release version to compile, as shown in Figure (3) and Figure (4).
The effect is as follows:
Method 2 Modify by *.vcxproj
*.vcxproj is the path configuration file of the VS project, which contains Release and Debug environment configuration items, as follows:
// *.vcxproj
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
//..
<AdditionalIncludeDirectories>..\myCommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
//..
<AdditionalIncludeDirectories>..\myCommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
AdditionalIncludeDirectories is a configuration item for additional include directories, just fill in the header file path in it.
2.1 Determine the path relationship between the include directory and *.vcxproj
The include directory here refers specifically to myCommon, enter the project root directory (*.sln directory) where calcOne is located, and use tree /f to view the path relationship:
## 进入项目根目录
cd calcOne
## 查看路径关系
tree /f
2.2 Fill in the include directory
As can be seen from Figure (6), the include directory that needs to be filled is: ..\myCommon, just fill it in AdditionalIncludeDirectories, as shown in Figure (7):