# Cross-building glfw from x86\_64 source to arm64

**URL:** <https://discourse.glfw.org/t/cross-building-glfw-from-x86-64-source-to-arm64/3014>\
**Category:** support\
**Created:** [July 1, 2026, 12:20pm UTC](https://discourse.glfw.org/t/cross-building-glfw-from-x86-64-source-to-arm64/3014 "2026-07-01T12:20:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/john/32/1076_2.png) [@John](https://discourse.glfw.org/u/John)\
**Post date:** [July 1, 2026, 12:20pm UTC](https://discourse.glfw.org/t/cross-building-glfw-from-x86-64-source-to-arm64/3014/1 "2026-07-01T12:20:12Z")

</div>

My host machine is a Linux x86\_64.  
My target is a SoC Linux arm64.

They both have the required graphics processors.

I 'm provided with a custom toolchain with gcc/g++ compilers and a sysroot.

How to build the glfw library on my machine and for the target using CMake?

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [July 1, 2026, 12:33pm UTC](https://discourse.glfw.org/t/cross-building-glfw-from-x86-64-source-to-arm64/3014/2 "2026-07-01T12:33:46Z")

</div>

Have you read the cross compile documentation from CMake?

> **[Cross Compiling With CMake — Mastering CMake](https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html)**

I haven’t tried this myself, but it looks like a good start.

---

<div class="post-metadata">

**Author:** ![John](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/john/32/1076_2.png) [@John](https://discourse.glfw.org/u/John)\
**Post date:** [July 1, 2026, 2:04pm UTC](https://discourse.glfw.org/t/cross-building-glfw-from-x86-64-source-to-arm64/3014/3 "2026-07-01T14:04:59Z")

</div>

I tried using the following cmake build settings.

`cmake -S ../glfw-3.4/ -B build-arm`  
`-DCMAKE_SYSTEM_NAME=Linux`  
`-DCMAKE_SYSTEM_PROCESSOR=aarch64`  
`-DCMAKE_C_COMPILER=toolchain/aarch64/bin/aarch64-linux-gnu-gcc`  
`-DCMAKE_CXX_COMPILER=toolchain/aarch64/bin/aarch64-linux-gnu-g++`  
`-DCMAKE_SYSROOT=toolchain/aarch64/aarch64-linux-gnu/sysroot`  
`-DGLFW_BUILD_WAYLAND=OFF`  
`-DGLFW_BUILD_X11=ON`

After I run `make` in `build-arm` folder I get  
`Scanning dependencies of target glfw`  
`[1%] Building C object src/CMakeFiles/glfw.dir/context.c.o`  
`In file included from /glfw-3.4/src/platform.h:81,`  
`from /glfw-3.4/src/internal.h:325,`  
`from /glfw-3.4/src/context.c:28:`  
`/glfw-3.4/src/x11_platform.h:32:10: fatal error: X11/Xlib.h: No such file or directory`  
`#include <X11/Xlib.h>`

Is it possible that the `sysroot` don’t have X11 installed?

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [July 1, 2026, 5:04pm UTC](https://discourse.glfw.org/t/cross-building-glfw-from-x86-64-source-to-arm64/3014/4 "2026-07-01T17:04:00Z")

</div>

First I would check that you can build GLFW normally for your Linux x86\_64 system and then try a cross compile, making sure to read the CMake cross compile instructions carefully. I have no experience myself with this so probably can’t help any further.
