在cl.exe中设置PlatformTools [英] Set PlatformTools in cl.exe

查看:87
本文介绍了在cl.exe中设置PlatformTools的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试构建WolfSSL,它使用  CryptAcquireContext   function Windows API的
。我正在尝试使用'cl.exe'来构建它。我不想使用'nmake.exe'或'MSBuild.exe',只是简单的'cl.exe'。



如果我使用Visual Studio对于构建,我可以设置  < PlatformToolset> v120< / PlatformToolset> 'vcxproj'文件中的参数
,它定义了平台工具集版本。设置此选项后,Visual Studio将编译并链接代码而不会出错。



如果我尝试编译并链接'cl.exe',我得到以下内容消息:



error
LNK2019:未解析的外部符号__imp__C ryptAcquireContextA @ 20



由于Visual Studio成功,问题不是由丢失的SDK引起的。



"cl.exe"的文档不包含有关平台工具集的任何信息。我​​尝试添加  / p:PlatformToolset = v120
但似乎只有MSBuild接受此选项。



虽然我的问题描述很长,但我的问题很简单。如何为'cl.exe'定义平台工具集?


- - 编辑 -


在/ link选项修复链接问题后添加& Advapi32.lib。
但这是否意味着我必须指示链接器使用我使用的每个本机Windows".lib"文件?我没有必要为标准库执行此操作。有没有办法强迫 
cl  到
会自动包含所有本机Windows".lib"文件,就像它对标准库一样吗?

解决方案

根据文档,这是一个链接器错误,你应该用
Advapi32.lib链接你的文件。尝试添加这个选项到你的CL命令:
/ link Advapi32.lib


也许工具集不是可以为CL指定的东西。


I'm trying to build WolfSSL, which uses the CryptAcquireContext function of the Windows API. I'm trying to build it using 'cl.exe'. I don't want to use 'nmake.exe' nor 'MSBuild.exe', just plain 'cl.exe'.

If I use Visual Studio for building, I can set the <PlatformToolset>v120</PlatformToolset>parameter in the 'vcxproj' file, which defines the platform toolset version. With this option set, Visual Studio compiles and links the code without error.

If I try compiling and linking with 'cl.exe', I get the following message:

error LNK2019: unresolved external symbol __imp__CryptAcquireContextA@20

Since Visual Studio succeeds, the problem is not caused by a missing SDK.

The documentation for 'cl.exe' does not include any information on platform toolset. I tried adding /p:PlatformToolset=v120, but it seems only MSBuild accepts this option.

Though the description of my problem is long, my question is simple. How do I define the platform toolset for 'cl.exe'?

-- EDIT --

Adding Advapi32.lib after the /link option fixed the linking problem. However does that mean I have to instruct the linker to use every native Windows '.lib' file I use? I do not have to do that for the standard library. Is there a way to force cl to include all native Windows '.lib' files automatically, just like it does with the standard library?

解决方案

According to documentation, this is a linker error, and you should link your files with Advapi32.lib. Try adding this option to your CL command: /link Advapi32.lib.

Maybe toolset is not a thing that can be specified for CL.


这篇关于在cl.exe中设置PlatformTools的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆