[CMake] How to force use of Windows 64bit link.exe?

Paul Smith paul at mad-scientist.net
Thu Nov 9 08:57:25 EST 2017


On Wednesday, November 8, 2017, Shoaib Meenai <smeenai at fb.com> wrote:
> Running cmake from an x64 developer command prompt and passing
> -Thost=x64 to cmake should do the trick.

Thanks for the response!

I'm not sure what you mean by "an x64 developer command": my builds are
invoked in an automated way from a CI build agent (Bamboo, in my case)
not from Visual Studio or from a command shell.  There is no vcvarsall
configuration in my environment before I invoke cmake.

I tried adding the -Thost=x64 to my cmake invocation, which does indeed
sound like what I want based on the cmake docs, but cmake failed.  The
CMakeError.log says:

  Project "D:\builds\CMakeFiles\3.5.2\CompilerIdC\CompilerIdC.vcxproj"
on node 1 (default targets).
  C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57
,5): error MSB8020: The build tools for host=x64 (Platform Toolset =
'host=x64') cannot be found. To build using the host=x64 build tools,
please install host=x64 build tools.  Alternatively, you may upgrade to
the current Visual Studio tools by selecting the Project menu or right-
click the solution, and then selecting "Retarget solution".
[D:\builds\CMakeFiles\3.5.2\CompilerIdC\CompilerIdC.vcxproj]
  Done Building Project
"D:\builds\CMakeFiles\3.5.2\CompilerIdC\CompilerIdC.vcxproj" (default
targets) -- FAILED.

However as far as I can see, I DO have the 64bit Visual Studo
installed.  My "Programs and Features" lists "Microsof Visual C++ 2015
Redistributable (x64) - 14.0.24212" (as well as "(x86)")

There was nothing useful in the CMakeOutput.log (just "The system is:
Windows - 6.2.9200 - AMD64")

On Wed, 2017-11-08 at 17:40 -0600, R0b0t1 wrote:
> Perhaps more
advisable is selecting the Visual Studio generator and
> passing in the platform at the end: "Visual Studio 15 2017 Win64."

This isn't what I'm looking for, unfortunately.  I'm already passing
the -A x64 option to cmake, which is equivalent to what you're
suggesting.  This selects the _output_ architecture: that is, it
instructs cmake to generate my programs as 64bit executables.  That
works fine.

What I'm trying to do is get cmake to invoke the 64bit versions of the
Visual Studio compiler and (in particular) linker; i.e., instead of
linking my program using x86_amd64\link.exe (which is a 32bit link.exe
program that can generate 64bit output) I want to link using
amd64\link.exe, which is a 64bit program which can generate 64bit
output.


More information about the CMake mailing list