# Build ONNX Runtime

## In this learning path

- [Introduction](https://learn.arm.com/learning-paths/laptops-and-desktops/win_on_arm_build_onnxruntime/)
- [Set up your Environment](https://learn.arm.com/learning-paths/laptops-and-desktops/win_on_arm_build_onnxruntime/1-dev-env-setup/)
- [Build ONNX Runtime](https://learn.arm.com/learning-paths/laptops-and-desktops/win_on_arm_build_onnxruntime/2-build-onnxruntime/)
- [Build ONNX Runtime Generate() API](https://learn.arm.com/learning-paths/laptops-and-desktops/win_on_arm_build_onnxruntime/3-build-onnxruntime-generate-api/)
- [Run Phi3 Model](https://learn.arm.com/learning-paths/laptops-and-desktops/win_on_arm_build_onnxruntime/4-run-benchmark-on-woa/)
- [Next Steps](https://learn.arm.com/learning-paths/laptops-and-desktops/win_on_arm_build_onnxruntime/_next-steps/)

## Build ONNX Runtime for Windows on Arm
Now that your environment is set up, you’re ready to build the ONNX Runtime inference engine.

ONNX Runtime is an open-source engine for accelerating machine learning model inference, especially those in the Open Neural Network Exchange (ONNX) format.

ONNX Runtime is optimized for high performance and low latency, and is widely used in production deployments.

> You can learn more about ONNX Runtime by reading the [ONNX Runtime Overview](https://onnxruntime.ai/).

### Clone the ONNX Runtime repository
Open a command prompt for Visual Studio to set up the environment, which includes paths to the compiler, linker, utilities, and header files.

Then, create your workspace and clone the repository:

```
cd C:\Users\%USERNAME%
mkdir repos\lp
cd repos\lp
git clone --recursive https://github.com/Microsoft/onnxruntime.git
cd onnxruntime
git checkout 4eeefd7260b7fa42a71dd1a08b423d5e7c722050
```

> You might be able to use a later commit. These steps have been tested with the commit `4eeefd7260b7fa42a71dd1a08b423d5e7c722050`.

### Build ONNX Runtime
To build the ONNX Runtime shared library, use one of the following configurations:

- **Release** configuration, for a build optimized for performance but without debug information:

```
.\build.bat --config Release --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --skip_tests
```

- **RelWithDebInfo** configuration, which includes debug symbols for profiling or inspection:

```
.\build.bat --config RelWithDebInfo --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --skip_tests
```

### Resulting Dynamically Linked Library
When the build is complete, you’ll find the `onnxruntime.dll` dynamically linked library in the following respective directories:

- For **Release** build:

```
dir .\build\Windows\Release\Release\onnxruntime.dll
```

- For **RelWithDebInfo** build:

```
dir .\build\Windows\RelWithDebInfo\RelWithDebInfo\onnxruntime.dll
```
