在命令行上编译 C++/CX
Compiling C++/CX on the command line
当我尝试在命令行上编译 C++/CX 程序时出现链接器错误 fatal error C1107: could not find assembly 'platform.winmd': please specify the assembly search path using /AI or by setting the LIBPATH environment variable
。
按照此页面上的说明操作后,错误是相同的:https://msdn.microsoft.com/en-us/library/dn769142.aspx(总结:运行 cl /ZW /EHsc source.cpp
来自 VS2015 开发人员命令提示)
我也尝试了 运行ning vcvarsall.bat x86 store
来自 VS2015 的开发人员命令提示符 但我仍然遇到同样的错误(同样的错误也会发生在运行ning vcvarsall.bat x86 store
来自普通命令提示符)。
UPDATE: Apparently this bug has been fixed in VS2015 Update 1, I have not been able to test myself yet though.
问题中提到的文档中缺少一些命令行参数,这里是编译小程序所需的完整命令行:
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\References\Windows.Foundation.FoundationContract.0.0.0\Windows.Foundation.FoundationContract.winmd"
/FU"C:\Program Files (x86)\Windows Kits\References\Windows.Foundation.UniversalApiContract.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 程序时出现链接器错误 fatal error C1107: could not find assembly 'platform.winmd': please specify the assembly search path using /AI or by setting the LIBPATH environment variable
。
按照此页面上的说明操作后,错误是相同的:https://msdn.microsoft.com/en-us/library/dn769142.aspx(总结:运行 cl /ZW /EHsc source.cpp
来自 VS2015 开发人员命令提示)
我也尝试了 运行ning vcvarsall.bat x86 store
来自 VS2015 的开发人员命令提示符 但我仍然遇到同样的错误(同样的错误也会发生在运行ning vcvarsall.bat x86 store
来自普通命令提示符)。
UPDATE: Apparently this bug has been fixed in VS2015 Update 1, I have not been able to test myself yet though.
问题中提到的文档中缺少一些命令行参数,这里是编译小程序所需的完整命令行:
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\References\Windows.Foundation.FoundationContract.0.0.0\Windows.Foundation.FoundationContract.winmd"
/FU"C:\Program Files (x86)\Windows Kits\References\Windows.Foundation.UniversalApiContract.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.