msbuild 链接步骤未运行
msbuild Link step doesn't run
我正在尝试使用MSBuild构建一个非常简单的C程序。以前这是由一个使用Visual Studio的实习生组合在一起的,但我们不会在这里使用VS,我希望用MSBuild构建它,这样我就可以自动化它。
我按照 MSDN 和其他参考文档的演练从头开始构建了我的 vcxproj 文件。我能够编译 obj 文件没有问题,但链接步骤似乎从未运行过,所以我没有得到可执行输出。
AppDrv.c 文件中有一个名为 main 的函数,是否可以安全地假设链接器将检测为入口点,或者我是否需要手动告诉 msbuild 这是怎么回事?
这是我的全部vcxproj。我在文档中找不到任何说我需要告诉它链接的内容,如果 CL 步骤完成正常,它不应该自动发生吗?我是否需要以某种方式显式列出要链接的 obj 文件,或者 MSBuild 可以自己解决这个问题?
<Project DefaultTargets="Build" ToolsVersion="14.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>Console</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)Microsoft.Cpp.props" />
<!--Import Project="$(UserRootDir)Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /-->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(UniversalCRT_IncludePath)$(ProjectDir)helperinclude;$(WindowsSDK_IncludePath)$(VC_IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<CompileAs>CompileAsC</CompileAs>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>slip_windows_helper.exe</OutputFile>
<ShowProgress>LinkVerbose</ShowProgress>
</Link>
</ItemDefinitionGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(UniversalCRT_IncludePath)$(ProjectDir)helperinclude;$(WindowsSDK_IncludePath)$(VC_IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<CompileAs>CompileAsC</CompileAs>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="$(ProjectDir)helpersrcAppDrv.c" />
<ClCompile Include="$(ProjectDir)helpersrcBuffers.c" />
<ClCompile Include="$(ProjectDir)helpersrcSingleThreadAsync.c" />
<ClCompile Include="$(ProjectDir)helpersrcSlip.c" />
<ClCompile Include="$(ProjectDir)helpersrcUtils.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(ProjectDir)helperincludeAppDrv.h" />
<ClInclude Include="$(ProjectDir)helperincludeBuffers.h" />
<ClInclude Include="$(ProjectDir)helperincludeSingleThreadAsync.h" />
<ClInclude Include="$(ProjectDir)helperincludeSlip.h" />
<ClInclude Include="$(ProjectDir)helperincludeUtils.h" />
<ClInclude Include="$(ProjectDir)helperincludeSharedHeader.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)Microsoft.Cpp.Targets" />
<Target Name="Info">
<Message Text="Target to output MSBuild information" />
<Message Text="OutputAssembly: $(OutputAssembly)" />
<Message Text="VCTargetsPath: $(VCTargetsPath)" />
<Message Text="Includes: $(IncludePath)" />
<Message Text="VC_IncludePath:$(VC_IncludePath)" />
<Message Text="WindowsSDK_IncludePath:$(WindowsSDK_IncludePath)" />
<Message Text="the property config is: $(Configuration)" />
<Message Text="final output directory: $(OutDir)" />
</Target>
</Project>
这是我用来启动构建的命令:
MSBuild.exe slipwinhelper.vcxproj /p:configuration=Debug /p:platform=Win32 /p:OutDir=target /nologo /t:Clean;Build;Info
更新:我让它通过覆盖 AfterBuild 事件来运行链接任务:
<Target Name="AfterBuild">
<Link Sources="DebugAppDrv.obj;DebugBuffers.obj;DebugSingleThreadAsync.obj;DebugSlip.obj;DebugUtils.obj" />
</Target>
但是现在它在代码中的 SetupApi 调用上给了我未解决的外部。我尝试将子系统更改为Windows,这似乎不起作用。
与 VS 生成的文件的快速比较显示了一系列差异/缺乏属性,包括来自 VS 的文件具有
<ConfigurationType>Application</ConfigurationType>
而您正在指定Console
这不是MSBuideal识别的东西。
相关文章:
- CMake-按正确顺序将项目与C运行时对象文件链接
- C++ 运行时链接器错误 (liblog4cpp.so.5) Eclipse
- 运行 C++ 单元测试时LNK2005链接错误
- 'make check' GLIBC 运行时的链接问题
- 如何在 android ndk 上链接 C 和 C++ 代码,以及 C 和 C++ 运行时库(包括 STL)?
- 为什么每当我尝试运行此链接列表删除功能时都会收到分段错误错误?
- 为什么C++可执行文件在与较新的libstdc++.so链接时运行得更快?
- 生成文件无法在运行时链接库
- 微控制器的首次 gcc 链接器脚本编译但不运行
- 运行程序时找不到共享对象库,但在编译过程中链接了它
- C++:链接库两次,全局构造函数运行两次吗?
- std :: list(双重链接列表)未知运行时错误
- C++ / GoogleTest - 如何在链接目录中为每个测试运行安装程序
- 模型依赖关系目标,在运行时链接
- 动态加载库和运行时误解的显式链接
- 不满意的链接错误,当使用LLVM运行javacpp预设时
- CMake:运行链接命令时出错:%1不是有效的Win32应用程序
- 无法通过 VIM 运行链接脚本
- CMake(Android工具链)-运行链接命令时出错:没有这样的文件或目录
- 无法让谷歌测试与 ubuntu 一起运行(链接器错误)