在命令行上编译C

在命令行上编译C

本文介绍了在命令行上编译C ++ / CX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到链接器错误致命错误C1107:找不到程序集platform.winmd:请指定程序集搜索路径使用/ AI或通过设置LIBPATH环境变量

I get the linker error fatal error C1107: could not find assembly 'platform.winmd': please specify the assembly search path using /AI or by setting the LIBPATH environment variable when I try to compile a C++/CX program on the command line.

在我按照本页上的说明执行后,错误是一样的:(总结:从VS2015的开发人员命令提示符运行 cl / ZW / EHsc source.cpp

The error is the same after I followed the instructions on this page: https://msdn.microsoft.com/en-us/library/dn769142.aspx (to summarize: run cl /ZW /EHsc source.cpp from the Developer Command Prompt for VS2015)

我也试过从开发人员命令提示符VS2015运行 vcvarsall.bat x86 store 但我仍然得到相同的错误当从纯命令提示符处运行 vcvarsall.bat x86 store 时也会发生同样的错误。

I also tried running vcvarsall.bat x86 store from the Developer Command Prompt for VS2015 but I still get the same error (the same error also happens when running vcvarsall.bat x86 store from a plain command prompt).

推荐答案

由于问题中提到的文档中缺少一些命令行参数,这里是编译一个小程序所需的完整命令行:

As it turns out some command line parameters are missing from the documentation mentioned in the question, here is the full command line required to compile a small program:

cl /ZW
   /ZW:nostdlib
   /D WINAPI_FAMILY=WINAPI_FAMILY_APP
   /D __WRL_NO_DEFAULT_LIB__
   /Gm-
   /EHsc
   /MDd
   /FU"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\store\references\platform.winmd"
   /FU"C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.FoundationContract\1.0.0.0\Windows.Foundation.FoundationContract.winmd"
   /FU"C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.UniversalApiContract\1.0.0.0\Windows.Foundation.UniversalApiContract.winmd"
   smurf.cpp
   /link /SUBSYSTEM:CONSOLE

其中 smurf.cpp 包含:

using namespace Platform;

int main(Platform::Array<Platform::String^>^ args)
{
    Platform::Details::Console::WriteLine("This is a C++/CX program.");
}

将会成功列印:

C:\Users\Mikael>smurf.exe
This is a C++/CX program.

这篇关于在命令行上编译C ++ / CX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-05 19:38