# Linux cross-compile x64 to aarch64

**URL:** https://discourse.cmake.org/t/linux-cross-compile-x64-to-aarch64/1752
**Category:** Usage
**Created:** [August 26, 2020, 11:32pm UTC](https://discourse.cmake.org/t/linux-cross-compile-x64-to-aarch64/1752 "2020-08-26T23:32:14Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Dakon](https://discourse.cmake.org/user_avatar/discourse.cmake.org/dakon/32/854_2.png) [@Dakon](https://discourse.cmake.org/u/Dakon)
#### Post date: [September 27, 2020, 7:54pm UTC](https://discourse.cmake.org/t/linux-cross-compile-x64-to-aarch64/1752/4 "2020-09-27T19:54:02Z")

</div>

Mine looks like this:

```cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

# specify the cross compiler
set(CMAKE_C_COMPILER /somewhere/bin/aarch64-unknown-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER /somewhere/bin/aarch64-unknown-linux-gnueabi-g++)

# where is the target environment
set(CMAKE_FIND_ROOT_PATH /somewhere/sysroot)
set(CMAKE_SYSROOT /somewhere/sysroot)

# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

# automatically use the cross-wrapper for pkg-config
set(PKG_CONFIG_EXECUTABLE "/somewhere/bin/aarch64-unknown-linux-gnueabi-pkg-config" CACHE FILEPATH "pkg-config executable")

```

---

_[View the full topic](https://discourse.cmake.org/t/linux-cross-compile-x64-to-aarch64/1752)._
