通过命令提示编译c++项目
Compiling c++ project through the command prompt
我很难弄清楚要在我创建的xml文件中填充什么字段。我一直试图遵循"使用MSBuild创建一个Visual c++项目"(http://msdn.microsoft.com/en-us/library/dd293607.aspx),但我被困在xml部分。所以字段是:
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<Import Project="$(VCTargetsPath)Microsoft.Cpp.default.props" />
<PropertyGroup>
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)Microsoft.Cpp.props" />
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="main.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)Microsoft.Cpp.Targets" />
</Project>
我知道我必须改变的唯一部分是Item组部分,以匹配我所有的。cpp和。h文件。所有字段都是必需的吗?你能给每个导入项目中的$(VCTargetsPath)一个例子吗?这似乎很简单,但只有在第一次这样做之后。谢谢。
VCTargetsPath是工具集的属性,在注册表中定义。在您的示例中,对于ToolsVersion="12"
,注册表位置将是HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSBuildToolsVersions12.0
。通常,当您安装适当的SDK时,工具集会自动配置。
老实说,我从来没有在编辑器中使用msbuild创建c++项目文件,总是让vs为我做这件事,并通过我单独的自定义构建文件包含/调用vcxproject文件…然而,TargetPath,是为MSBuild的c++配置的目标目录,在我的机器上安装了vs 2013(配置为使用vc++ 12.0工具):C:Program Files (x86)MSBuild Microsoft.Cppv4.0V120.
这些导入定义了ClInclude任务和您的工具支持的所有其他c++相关任务。
相关文章:
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 无法在 CLion 中构建 C++ 项目
- 运行同一解决方案的另一个项目的项目
- CMake-按正确顺序将项目与C运行时对象文件链接
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 欧拉项目#8答案是大以获得有效答案
- 从链接列表c++中删除一个项目
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 既然存在危险,为什么项目要使用-I include开关
- cmake在我的项目中所需的所有静态库都不成功
- QT通过C++添加映射QML项目
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 在linux上调试巨大的C++项目
- 在其他文件中创建类时在 c++ 项目中不起作用
- 使外部项目可用于find_package CMake
- 在子目录中使用target_sources()命令时用于单元测试(qtest)的项目结构
- 使用外部SDK工具链文件在VisualStudio上生成项目编译错误
- 如何维护资源管理器项目视图中当前可见的项目列表
- 错误-我无法在VS2019中打开新的Qt项目
- 你能检查一下为什么在这个代码中从链接列表中删除项目不起作用吗