# How can I compile GLFW for Windows on Arm?

**URL:** <https://discourse.glfw.org/t/how-can-i-compile-glfw-for-windows-on-arm/2699>\
**Category:** support\
**Created:** [July 26, 2024, 3:18am UTC](https://discourse.glfw.org/t/how-can-i-compile-glfw-for-windows-on-arm/2699 "2024-07-26T03:18:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![asheryoung10](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/asheryoung10/32/955_2.png) [@asheryoung10](https://discourse.glfw.org/u/asheryoung10)\
**Post date:** [July 26, 2024, 3:18am UTC](https://discourse.glfw.org/t/how-can-i-compile-glfw-for-windows-on-arm/2699/1 "2024-07-26T03:18:26Z")

</div>

I am developing on one of the new snapdragon x elite laptops that ships with windows on arm and would like to compile a static library for native arm64.

I can’t seem to find instructions on how to do so, both the cmake configurations and build guides provide details with the assumption that windows is x86. Do I need to avoid cmake and manually compile or did I just fumble the cmake configuration?

My toolchain of choice is llvm-mingw with UCRT ([GitHub - mstorsjo/llvm-mingw: An LLVM/Clang/LLD based mingw-w64 toolchain](https://github.com/mstorsjo/llvm-mingw)) and would be very happy if I can avoid visual studio.

---

<div class="post-metadata">

**Author:** ![mmozeiko](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/mmozeiko/32/29_2.png) [@mmozeiko](https://discourse.glfw.org/u/mmozeiko)\
**Post date:** [July 26, 2024, 3:42am UTC](https://discourse.glfw.org/t/how-can-i-compile-glfw-for-windows-on-arm/2699/2 "2024-07-26T03:42:49Z")

</div>

I don’t think there is anything special you need to do to target arm64 Windows than for x86 Windows.

You just get the llvm-build that runs on your host (x86\_64 if x86, aarch64 if on arm64), and then run cmake as usual.

Here’s me running it on x86 windows, but targeting arm64 and using Ninja for build:

```auto
C:\test>set PATH=c:\test\llvm-mingw-20240619-ucrt-x86_64\bin;%PATH%                                                                                   

C:\test>cmake -S glfw -B glfw.build -G Ninja -DCMAKE_C_COMPILER=aarch64-w64-mingw32-gcc.exe -DCMAKE_AR=aarch64-w64-mingw32-ar.exe
-- The C compiler identification is Clang 18.1.8
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/test/llvm-mingw-20240619-ucrt-x86_64/bin/aarch64-w64-mingw32-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Including Win32 support
-- Looking for dinput.h
-- Looking for dinput.h - found
-- Looking for xinput.h
-- Looking for xinput.h - found
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Documentation generation requires Doxygen 1.9.8 or later
-- Configuring done (2.2s)
-- Generating done (0.1s)
-- Build files have been written to: C:/test/glfw.build

C:\test>ninja -C glfw.build triangle-opengl
ninja: Entering directory `glfw.build'
[25/25] Linking C executable examples\triangle-opengl.exe

C:\test>llvm-objdump --file-headers glfw.build\examples\triangle-opengl.exe | findstr architecture
architecture: aarch64

```

It has created examples\triangle-opengl.exe that is native arm64 binary. And it has built src\libglfw.a static library too.

---

<div class="post-metadata">

**Author:** ![asheryoung10](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/asheryoung10/32/955_2.png) [@asheryoung10](https://discourse.glfw.org/u/asheryoung10)\
**Post date:** [July 26, 2024, 3:45am UTC](https://discourse.glfw.org/t/how-can-i-compile-glfw-for-windows-on-arm/2699/3 "2024-07-26T03:45:57Z")

</div>

Thank you! I will try this right now

---

<div class="post-metadata">

**Author:** ![asheryoung10](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/asheryoung10/32/955_2.png) [@asheryoung10](https://discourse.glfw.org/u/asheryoung10)\
**Post date:** [July 26, 2024, 3:59am UTC](https://discourse.glfw.org/t/how-can-i-compile-glfw-for-windows-on-arm/2699/4 "2024-07-26T03:59:05Z")

</div>

Worked like a charm! I think I couldn’t get it working earlier because I didn’t specify the archiver maybe? I had attempted this in visual studio and in msys2 clangarm64 so many times, I wonder what I was doing wrong when using those build tools.

---

<div class="post-metadata">

**Author:** ![mmozeiko](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/mmozeiko/32/29_2.png) [@mmozeiko](https://discourse.glfw.org/u/mmozeiko)\
**Post date:** [July 26, 2024, 4:08am UTC](https://discourse.glfw.org/t/how-can-i-compile-glfw-for-windows-on-arm/2699/5 "2024-07-26T04:08:42Z")

</div>

With Visual Studio it is even simpler - you just need extra `-A` argument. Something like this should work:

```auto
cmake -G "Visual Studio 17 2022" -A arm64 -S glfw -B glfw.build
cmake --build glfw.build --target triangle-opengl

```
