Set PlatformTools in cl.exe

274 views Asked by At

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, as suggested here, 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 don 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?

0

There are 0 answers