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

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Paul Smith
Hi all.  I wonder if someone can help me get CMake to force Visual
Studio to run the 64bit linker instead of the 32bit linker.  By that I
mean, the link.exe binary built for 64bit, not a linker that produces a
64bit executable.

Sometimes (but not always) when I link my code I get an error from the
32bit link.exe and Visual Studio wants to automatically re-invoke the
64bit link.exe.  I would prefer that it just always starts with the
64bit version, rather than fail and retry.

I get errors like:

  LINK : the 32-bit linker
  (C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\link.exe)
  ran out of heap space; restarting link with the 64-bit linker

I run CMake with a generator like this:

  cmake.exe -G "Visual Studio 14 2015" -A x64 D:\builds\src

I want to convince cmake to tell Visual Studio to invoke the 64bit
link.exe at first, rather than waiting for a failure--the 64bit
link.exe is, I believe:

  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\link.exe

Does anyone know how to force that to happen?

BTW, I'm using CMake 3.5.2 at the moment.

Cheers!
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to force use of Windows 64bit link.exe?

Shoaib Meenai
Running cmake from an x64 developer command prompt and passing -Thost=x64 to cmake should do the trick.

On 11/8/17, 2:26 PM, "CMake on behalf of Paul Smith" <[hidden email] on behalf of [hidden email]> wrote:

    Hi all.  I wonder if someone can help me get CMake to force Visual
    Studio to run the 64bit linker instead of the 32bit linker.  By that I
    mean, the link.exe binary built for 64bit, not a linker that produces a
    64bit executable.
   
    Sometimes (but not always) when I link my code I get an error from the
    32bit link.exe and Visual Studio wants to automatically re-invoke the
    64bit link.exe.  I would prefer that it just always starts with the
    64bit version, rather than fail and retry.
   
    I get errors like:
   
      LINK : the 32-bit linker
      (C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\link.exe)
      ran out of heap space; restarting link with the 64-bit linker
   
    I run CMake with a generator like this:
   
      cmake.exe -G "Visual Studio 14 2015" -A x64 D:\builds\src
   
    I want to convince cmake to tell Visual Studio to invoke the 64bit
    link.exe at first, rather than waiting for a failure--the 64bit
    link.exe is, I believe:
   
      C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\link.exe
   
    Does anyone know how to force that to happen?
   
    BTW, I'm using CMake 3.5.2 at the moment.
   
    Cheers!
    --
   
    Powered by www.kitware.com
   
    Please keep messages on-topic and check the CMake FAQ at: https://urldefense.proofpoint.com/v2/url?u=http-3A__www.cmake.org_Wiki_CMake-5FFAQ&d=DwICAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=04uD08sTa71kZ1R71-0lfj2WhRqDAQ1MD4dFpTTvEMw&s=WUSP8DL8wol0uWj27DY-hr8Cxfo-wDIzw4VK8gxsYZA&e=
   
    Kitware offers various services to support the CMake community. For more information on each offering, please visit:
   
    CMake Support: https://urldefense.proofpoint.com/v2/url?u=http-3A__cmake.org_cmake_help_support.html&d=DwICAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=04uD08sTa71kZ1R71-0lfj2WhRqDAQ1MD4dFpTTvEMw&s=XPIwm3-OwRZY6iPlierCUC4nja73_1tN4MOrTmwjafU&e=
    CMake Consulting: https://urldefense.proofpoint.com/v2/url?u=http-3A__cmake.org_cmake_help_consulting.html&d=DwICAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=04uD08sTa71kZ1R71-0lfj2WhRqDAQ1MD4dFpTTvEMw&s=znr1l-FqO4cl2CO0FquPjJu2rb3VFT_FB6fK5Kl7jj4&e=
    CMake Training Courses: https://urldefense.proofpoint.com/v2/url?u=http-3A__cmake.org_cmake_help_training.html&d=DwICAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=04uD08sTa71kZ1R71-0lfj2WhRqDAQ1MD4dFpTTvEMw&s=HkOsuk57njZ5Gle8DHBws-Zxuye7VU87mKMu8Sj1Xa4&e=
   
    Visit other Kitware open-source projects at https://urldefense.proofpoint.com/v2/url?u=http-3A__www.kitware.com_opensource_opensource.html&d=DwICAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=04uD08sTa71kZ1R71-0lfj2WhRqDAQ1MD4dFpTTvEMw&s=PKDPXwr0OKmHvOmP0NDauxr8_gk81Twie9Bqc8IByuw&e=
   
    Follow this link to subscribe/unsubscribe:
    https://urldefense.proofpoint.com/v2/url?u=http-3A__public.kitware.com_mailman_listinfo_cmake&d=DwICAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=04uD08sTa71kZ1R71-0lfj2WhRqDAQ1MD4dFpTTvEMw&s=IMj1Uw3a24-XuV1oGDAnZFzXJiix5ZqSEg09HyKfLPU&e=
   

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to force use of Windows 64bit link.exe?

R0b0t1
On Wednesday, November 8, 2017, Shoaib Meenai <[hidden email]> wrote:
> Running cmake from an x64 developer command prompt and passing -Thost=x64 to cmake should do the trick.
>

Perhaps more advisable is selecting the Visual Studio generator and passing in the platform at the end: "Visual Studio 15 2017 Win64."

Per https://cmake.org/cmake/help/v3.10/generator/Visual%20Studio%2015%202017.html.

It might be wise to make 64 bit the default or at least more prominent. I had a hard time figuring this out.

Cheers,
    R0b0t1

> On 11/8/17, 2:26 PM, "CMake on behalf of Paul Smith" <[hidden email] on behalf of [hidden email]> wrote:
>
>     Hi all.  I wonder if someone can help me get CMake to force Visual
>     Studio to run the 64bit linker instead of the 32bit linker.  By that I
>     mean, the link.exe binary built for 64bit, not a linker that produces a
>     64bit executable.
>
>     Sometimes (but not always) when I link my code I get an error from the
>     32bit link.exe and Visual Studio wants to automatically re-invoke the
>     64bit link.exe.  I would prefer that it just always starts with the
>     64bit version, rather than fail and retry.
>
>     I get errors like:
>
>       LINK : the 32-bit linker
>       (C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\link.exe)
>       ran out of heap space; restarting link with the 64-bit linker
>
>     I run CMake with a generator like this:
>
>       cmake.exe -G "Visual Studio 14 2015" -A x64 D:\builds\src
>
>     I want to convince cmake to tell Visual Studio to invoke the 64bit
>     link.exe at first, rather than waiting for a failure--the 64bit
>     link.exe is, I believe:
>
>       C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\link.exe
>
>     Does anyone know how to force that to happen?
>
>     BTW, I'm using CMake 3.5.2 at the moment.
>
>     Cheers!
>     --
>
>     Powered by www.kitware.com
>
>     Please keep messages on-topic and check the CMake FAQ at: https://urldefense.proofpoint.com/v2/url?u=http-3A__www.cmake.org_Wiki_CMake-5FFAQ&d=DwICAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=04uD08sTa71kZ1R71-0lfj2WhRqDAQ1MD4dFpTTvEMw&s=WUSP8DL8wol0uWj27DY-hr8Cxfo-wDIzw4VK8gxsYZA&e=
>
>     Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
>     CMake Support: https://urldefense.proofpoint.com/v2/url?u=http-3A__cmake.org_cmake_help_support.html&d=DwICAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=04uD08sTa71kZ1R71-0lfj2WhRqDAQ1MD4dFpTTvEMw&s=XPIwm3-OwRZY6iPlierCUC4nja73_1tN4MOrTmwjafU&e=
>     CMake Consulting: https://urldefense.proofpoint.com/v2/url?u=http-3A__cmake.org_cmake_help_consulting.html&d=DwICAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=04uD08sTa71kZ1R71-0lfj2WhRqDAQ1MD4dFpTTvEMw&s=znr1l-FqO4cl2CO0FquPjJu2rb3VFT_FB6fK5Kl7jj4&e=
>     CMake Training Courses: https://urldefense.proofpoint.com/v2/url?u=http-3A__cmake.org_cmake_help_training.html&d=DwICAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=04uD08sTa71kZ1R71-0lfj2WhRqDAQ1MD4dFpTTvEMw&s=HkOsuk57njZ5Gle8DHBws-Zxuye7VU87mKMu8Sj1Xa4&e=
>
>     Visit other Kitware open-source projects at https://urldefense.proofpoint.com/v2/url?u=http-3A__www.kitware.com_opensource_opensource.html&d=DwICAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=04uD08sTa71kZ1R71-0lfj2WhRqDAQ1MD4dFpTTvEMw&s=PKDPXwr0OKmHvOmP0NDauxr8_gk81Twie9Bqc8IByuw&e=
>
>     Follow this link to subscribe/unsubscribe:
>     https://urldefense.proofpoint.com/v2/url?u=http-3A__public.kitware.com_mailman_listinfo_cmake&d=DwICAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=04uD08sTa71kZ1R71-0lfj2WhRqDAQ1MD4dFpTTvEMw&s=IMj1Uw3a24-XuV1oGDAnZFzXJiix5ZqSEg09HyKfLPU&e=
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to force use of Windows 64bit link.exe?

CHEVRIER, Marc
In reply to this post by Paul Smith
For that purpose, set the environment variable PreferredToolArchitecture with value x64.

On 08/11/2017 23:26, "CMake on behalf of Paul Smith" <[hidden email] on behalf of [hidden email]> wrote:

    Hi all.  I wonder if someone can help me get CMake to force Visual
    Studio to run the 64bit linker instead of the 32bit linker.  By that I
    mean, the link.exe binary built for 64bit, not a linker that produces a
    64bit executable.
   
    Sometimes (but not always) when I link my code I get an error from the
    32bit link.exe and Visual Studio wants to automatically re-invoke the
    64bit link.exe.  I would prefer that it just always starts with the
    64bit version, rather than fail and retry.
   
    I get errors like:
   
      LINK : the 32-bit linker
      (C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\link.exe)
      ran out of heap space; restarting link with the 64-bit linker
   
    I run CMake with a generator like this:
   
      cmake.exe -G "Visual Studio 14 2015" -A x64 D:\builds\src
   
    I want to convince cmake to tell Visual Studio to invoke the 64bit
    link.exe at first, rather than waiting for a failure--the 64bit
    link.exe is, I believe:
   
      C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\link.exe
   
    Does anyone know how to force that to happen?
   
    BTW, I'm using CMake 3.5.2 at the moment.
   
    Cheers!
    --
   
    Powered by www.kitware.com
   
    Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
   
    Kitware offers various services to support the CMake community. For more information on each offering, please visit:
   
    CMake Support: http://cmake.org/cmake/help/support.html
    CMake Consulting: http://cmake.org/cmake/help/consulting.html
    CMake Training Courses: http://cmake.org/cmake/help/training.html
   
    Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
   
    Follow this link to subscribe/unsubscribe:
    http://public.kitware.com/mailman/listinfo/cmake
   

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to force use of Windows 64bit link.exe?

Jano Svitok
In reply to this post by Paul Smith
-T host=x64 is your answer

(-G chooses platform/generated code; -T host= chooses platform of the toolset itself).

Alternatively to -T you can set ENV variable PreferredToolArchitecture=x64

See: https://stackoverflow.com/questions/19820718/how-to-make-visual-studio-use-the-native-amd64-toolchain


Jano

PS: I do not reply to the original message since I've just subscribed.

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to force use of Windows 64bit link.exe?

Paul Smith
In reply to this post by R0b0t1
On Wednesday, November 8, 2017, Shoaib Meenai <[hidden email]> 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.
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake