Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 对于单个cpp文件,Visual Studio编译选项将灰显_C++_Visual Studio_Visual Studio 2015_Linkage_Vcxproj - Fatal编程技术网

C++ 对于单个cpp文件,Visual Studio编译选项将灰显

C++ 对于单个cpp文件,Visual Studio编译选项将灰显,c++,visual-studio,visual-studio-2015,linkage,vcxproj,C++,Visual Studio,Visual Studio 2015,Linkage,Vcxproj,我被要求帮助一位同事解决一个常见解决方案中某个项目中的神秘构建错误。构建错误发生在链接阶段,在静态库(a.lib)中定义的类构造函数在包含该a.lib的库(b.lib)中使用时,找不到该类构造函数。经过仔细调查,我发现: 构造函数已在类中正确定义 该类在属于项目的cpp文件中定义 如果用户尝试使用intellisense导航到cpp文件或类构造函数,一切都会按预期进行 vcxproj文件ClCompile项目组: ... <ClCompile Include="Source\CMYKOVB

我被要求帮助一位同事解决一个常见解决方案中某个项目中的神秘构建错误。构建错误发生在链接阶段,在静态库(a.lib)中定义的类构造函数在包含该a.lib的库(b.lib)中使用时,找不到该类构造函数。经过仔细调查,我发现:

  • 构造函数已在类中正确定义
  • 该类在属于项目的cpp文件中定义
  • 如果用户尝试使用intellisense导航到cpp文件或类构造函数,一切都会按预期进行 vcxproj文件ClCompile项目组:

    ...
    <ClCompile Include="Source\CMYKOVBLab.cpp" />
    <ClInclude Include="Source\CMYKOBGLab.cpp" />  <--- The file is here.
    <ClCompile Include="Source\CMYKOVBRGB.cpp" />
    ...
    
    。。。
    
    在VS 2015中,.vcxproj项目文件中定义的compile include文件应按字典顺序排列

    这在VS 2017中不再需要,但如果不尊重,VS 2015可能会造成这种混乱

    您的同事已手动修改了.vcxproj项目文件,以包含该文件,但他不遵守词典顺序。您只需从项目中删除该文件,然后再次添加该文件。Visual Studio将把它放在正确的位置,您的构建将成功


    希望这也能帮助其他人。

    手动修改或使用git/svn。在结构化文件上天真地使用
    diff
    的工具与使用XML文件的Visual Studio 2015之间存在着一种相当恶劣的交互,对其格式的解释相当严格。