# flag to force windows to build as x64 instead of x86?

**URL:** <https://discourse.cmake.org/t/flag-to-force-windows-to-build-as-x64-instead-of-x86/7648>\
**Category:** Code\
**Tags:** os:windows\
**Created:** [March 9, 2023, 3:01pm UTC](https://discourse.cmake.org/t/flag-to-force-windows-to-build-as-x64-instead-of-x86/7648 "2023-03-09T15:01:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsoneaday](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jsoneaday/32/3243_2.png) [@jsoneaday](https://discourse.cmake.org/u/jsoneaday)\
**Post date:** [March 9, 2023, 3:01pm UTC](https://discourse.cmake.org/t/flag-to-force-windows-to-build-as-x64-instead-of-x86/7648/1 "2023-03-09T15:01:00Z")

</div>

Hello I have a x64 windows machine with visual studio 2022 and when I try and compile c++ code it runs the build as x86. Is there some flag to force x64 build?

---

<div class="post-metadata">

**Author:** ![jsoneaday](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jsoneaday/32/3243_2.png) [@jsoneaday](https://discourse.cmake.org/u/jsoneaday)\
**Post date:** [March 9, 2023, 6:02pm UTC](https://discourse.cmake.org/t/flag-to-force-windows-to-build-as-x64-instead-of-x86/7648/2 "2023-03-09T18:02:26Z")

</div>

CXX= is the requirement

---

<div class="post-metadata">

**Author:** ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)\
**Post date:** [March 9, 2023, 9:32pm UTC](https://discourse.cmake.org/t/flag-to-force-windows-to-build-as-x64-instead-of-x86/7648/3 "2023-03-09T21:32:03Z")

</div>

That doesn’t make any sense.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [March 11, 2023, 1:13am UTC](https://discourse.cmake.org/t/flag-to-force-windows-to-build-as-x64-instead-of-x86/7648/4 "2023-03-11T01:13:02Z")

</div>

I agree. There’s not enough information to know if the 64bit developer prompt was used or not or whether the VS generator is being used (which should default to the host arch these days).
