Environment setup¶
Following documentation usessbt build tool.Other build tools that support Scala Native are:
Scala Native has the following build dependencies:
Java 8 or newer
sbt 1.5.8 or newer
LLVM/Clang 6.0 or newer
And following completely optional runtime library dependencies:
Boehm GC 7.6.0 (optional)
zlib 1.2.8 or newer (optional)
These are only required if you use the corresponding feature.
Installing sbt¶
macOS, Linux, and Windows
Please refer tothislink forinstructions for your operating system.
FreeBSD
pkginstallsbt
OpenBSD
pkg_addsbt
NetBSD
pkg_addscala-sbt
Installing clang and runtime dependencies¶
Scala Native requires Clang, which is part of theLLVM toolchain. The recommended LLVM version is themost recent available for your system provided that it works with ScalaNative. The Scala Native sbt plugin checks to ensure thatclang is at least the minimum version shown above.
Scala Native uses theImmixgarbage collector by default. You can use theBoehm garbage collector instead. Ifyou chose to use that alternate garbage collector both the nativelibrary and header files must be provided at build time.
If you use classes from thejava.util.zip for compressionzlib needs to be installed.
Note: Some package managers provide the library header files in separate-dev packages.
Here are install instructions for a number of operating systems ScalaNative has been used with:
macOS
brewinstallllvmbrewinstallbdw-gc# optionalNote 1: Xcode should work as an alternative if preferred:https://apps.apple.com/us/app/xcode/id497799835
Note 2: A version of zlib that is sufficiently recent comes with theinstallation of macOS.
Ubuntu
sudoaptinstallclanglibstdc++-12-devsudoaptinstalllibgc-dev# optionalArch Linux
sudopacman-Sllvmclangsudopacman-Sgc# optionalNote: A version of zlib that is sufficiently recent comes with theinstallation of Arch Linux.
Fedora 33
sudodnfinstallllvmclangsudodnfgroupinstall"Development Tools"sudodnfinstallgc-develzlib-devel# both optional
FreeBSD 12.4 and later
Note 1: Only AMD64 and ARM64 architectures are supported.
Note 2: Sufficiently recent versions of llvm and zlib come with theinstallation of FreeBSD.
pkginstallboehm-gc# optionalNote 3: Using the boehm GC with multi-threaded binaries doesn’t workout-of-the-box yet.
OpenBSD 7.5 and later
Note 1: OpenBSD support is experimental and limited to only AMD64architecture.
pkg_addboehm-gc# optionalNetBSD 9.3 and later
Note 1: NetBSD support is experimental and limited to only AMD64architecture.
pkg_addclangpkg_addboehm-gc# optionalNix/NixOS
wgethttps://raw.githubusercontent.com/scala-native/scala-native/main/scripts/scala-native.nixnix-shellscala-native.nix-AclangEnv
Windows
Corporate environments and Windows policies can affect the method usedto set up your environment. The following procedure involves downloadinginstallers and running the installers using Powershell (Administrative)to avoid some of these issues. If you have full access to your machinethen you can install using your favorite method.Chocolatey orScoop canbe substituted as needed or desired and are also mentioned above in theinstallingsbt documentation.
Download and install Visual Studio Community 2019
https://visualstudio.microsoft.com/
You may install it via the command line if needed.
>.\vs_community__<version>.exe
Select theWorkloads tab and thenDesktop development with C++checkbox. The defaults are fine. TheC++ Clang tools for Windows doesnot work so use the next step for details on installing LLVM.

Visual Studio install dialog showing options.¶
Download and install LLVM
https://github.com/llvm/llvm-project/releases/tag/llvmorg-12.0.1
SelectLLVM-12.0.1-win64.exe or newer. Digital signatures areprovided.
You may also install LLVM via the command line, and if needed, installit into yourC:\Users\<login>\AppData\Local directory. Theinstaller will addLLVM and the associated directories and files.
>.\LLVM-12.0.1-win64.exe
Add the binary location to your PATH
Using the install path above, you would add the following:
C:\Users\<login>\AppData\Local\LLVM\bin
Continue tosbt.
