Setup and Build Systems#
There are various resources on building ARM apps and libraries. External Resources highlights some of them. This chapter focuses mainly on NVIDIA-specific cases.
C/C++ Apps with CMake#
Running the CMake generator as is creates build files only for the host architecture.
It is therefore recommended to explicitly set the target architecture using the -A flag. Use:
cmake -A ARM64for native 64-bit ARM (ARM64) code incompatible with x86_64.cmake -A ARM64ECfor ARM64 Emulation Compatible (ARM64EC) code interoperable with x86_64.cmake -A x64for x86_64.
When setting the architecture explicitly, CMake defines the variable CMAKE_GENERATOR_PLATFORM, which allows target-specific instructions:
if ("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM64")
# ARM64-specific instructions
elseif ("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM64EC")
# ARM64EC-specific instructions
else()
# fallback
endif()
In case the target is not specified, variables like CMAKE_SYSTEM_PROCESSOR, WIN32, and MSVC facilitate platform detection.
Batch Files#
Build systems often interact with batch scripts.
It is recommended to use the vcvars***.bat family of scripts to prepare your development environment.
For example, call "%ProgramFiles%\Microsoft Visual Studio\18\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64_arm64 sets the environment up for cross-compilation from x86_64 to ARM64.
It sets the environment variables VSCMD_ARG_HOST_ARCH and VSCMD_ARG_TGT_ARCH to the host and target architectures.
These can then be used in a script to, for example, choose the correct target architecture for CMake:
if "%VSCMD_ARG_TGT_ARCH%"=="ARM64" (
cmake -A ARM64EC
) else if "%VSCMD_ARG_TGT_ARCH%"=="x64" (
cmake -A x64
) else (
echo "Unsupported architecture %VSCMD_ARG_TGT_ARCH%."
)
Outside of vcvars***.bat, the PROCESSOR_ARCHITECTURE variable always contains the host architecture.
(See WOW64 Implementation Details)
Cross-Compilation of C/C++ CUDA Apps for ARM64#
This section hightlights how to cross-compile C/C++ CUDA applications for ARM64 from an x86_64 host.
Setup#
To prepare for building ARM64 apps from an x86_64 host, open the Visual Studio Installer and Modify your existing Visual Studio 2026 installation as follows. Under the Individual Components tab, select the following:
Windows 11 SDK
C++ Universal Windows Platform support for ARM64/ARM64EC
MSVC Build Tools for ARM64/ARM64EC
ARM64 Remote Debugger
Click Install to finish the process.
Console#
On the x86_64 host, run the following:
:: Initialize the MSVC environment for ARM64 cross-compiling
set VSCMD_START_DIR=%cd%
call "%ProgramFiles%\Microsoft Visual Studio\18\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64_arm64
git clone https://github.com/NVIDIA/cuda-samples.git
cd cuda-samples\Samples\0_Introduction\vectorAdd
nvcc --use-local-env -I..\..\..\Common -o vectorAdd.exe vectorAdd.cu
Copy vectorAdd.exe to the ARM device and run it.
You should get the following output:
> vectorAdd.exe
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done
You can verify that this is an ARM64 executable with the link command:
> link /dump /headers vectorAdd.exe
[..]
FILE HEADER VALUES
AA64 machine (ARM64)
[..]
Microsoft Visual Studio#
With a supported Microsoft Visual Studio installation already present, the CUDA Toolkit installer installs the required Visual Studio integration components.
CMake#
CMake works with CUDA out of the box by picking up the ARM64 libraries from %CUDA_PATH%\lib\arm64.
Run the following on the x86_64 host:
git clone https://github.com/NVIDIA/CUDALibrarySamples.git
cd CUDALibrarySamples\cuBLAS\Level-3\gemm
mkdir BUILD
cd BUILD
cmake .. -A ARM64
cmake --build .
Instruct the generator to compile for ARM64 using -A ARM64.
Without this flag, it would pick x86_64 as the target platform.
Copy Debug\cublas_gemm_example.exe as well as %CUDA_PATH%\bin\arm64\cublas64_13.dll and cublasLt64_13.dll to the ARM device and run the executable.
You should get the following output:
> cublas_gemm_example.exe
A
1.00 3.00
2.00 4.00
=====
B
5.00 7.00
6.00 8.00
=====
C
23.00 31.00
34.00 46.00
=====
Cross-Compilation of C/C++ CUDA Apps for ARM64EC#
ARM64EC allows taking advantage of improved native performance while maintaining compatibility with x86_64 dependencies. Building ARM64EC apps with an x86_64 CUDA Toolkit is similar to cross-compiling for native ARM.
Console#
To enable ARM64EC, add /arm64EC to the host compiler flags, and /machine:arm64ec to the linker flags.
On the x86_64 host, run the following:
:: Initialize the MSVC environment for ARM64 cross-compiling
set VSCMD_START_DIR=%cd%
call "%ProgramFiles%\Microsoft Visual Studio\18\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64_arm64
git clone https://github.com/NVIDIA/cuda-samples.git
cd cuda-samples\Samples\0_Introduction\vectorAdd
nvcc --use-local-env -I..\..\..\Common\ ^
-Xcompiler "/arm64EC" -Xlinker "/machine:arm64ec" ^
-L"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.4\lib\x64" ^
-o vectorAdd.exe vectorAdd.cu
Copy vectorAdd.exe to the ARM device and run it.
You should get the following output:
> vectorAdd.exe
[Vector addition of 50000 elements]
Copy input data from the host memory to the CUDA device
CUDA kernel launch with 196 blocks of 256 threads
Copy output data from the CUDA device to the host memory
Test PASSED
Done
You can verify that this is an ARM64EC executable with the link command:
> link /dump /headers vectorAdd.exe
[..]
FILE HEADER VALUES
8664 machine (x64) (ARM64X)
[..]
Microsoft Visual Studio#
In Visual Studio, select Build -> Configuration Manager. Under Active solution platform, choose <New…>. Select ARM64EC as the new platform, choose x64 under Copy settings from, and enable Create new project platforms. Click OK.
ARM64EC is now the active platform for the solution. Confirm that the platform selector in the Visual Studio toolbar displays ARM64EC before continuing with CUDA and output-directory settings.
CMake#
Run the following on the x86_64 host:
git clone https://github.com/NVIDIA/CUDALibrarySamples.git
cd CUDALibrarySamples\cuBLAS\Level-3\gemm
mkdir BUILD
cd BUILD
cmake .. -A ARM64EC
cmake --build .
Copy Debug\cublas_gemm_example.exe as well as %CUDA_PATH%\bin\cublas64_13.dll and cublasLt64_13.dll to the ARM device and run the executable.
You should get the following output:
> cublas_gemm_example.exe
A
1.00 3.00
2.00 4.00
=====
B
5.00 7.00
6.00 8.00
=====
C
23.00 31.00
34.00 46.00
=====
External Resources#
Microsoft: Arm64EC - Build and port apps for native performance on Arm
ARM Learning Paths -> Laptops & Desktops -> Search for “Windows”. For example, see Build an application on Windows 11 using ARM64EC.
ARM: Install Guides -> Search for “Windows”
Porting applications to Arm64 using the Arm64EC ABI - Youtube