Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I build a statically linked executable with scala-native?

I would like to write a program using Scala Native but it has to run on a linux host (centos 6.5) with a very old glibc. So I would like to deploy that program as a statically linked executable, e.g. as golang does.

How do I build a statically linked executable with scala-native? Is it possible? If yes, how do I do it? If no, why not?

like image 643
gruenewa Avatar asked May 02 '26 22:05

gruenewa


1 Answers

The sbt option nativeLinkingOptions takes a Seq[String] of extra arguments which are passed verbatim to clang during linking.

Adding the following to the project build settings works for me in a quick test:

nativeLinkingOptions += "-static"
like image 131
arashi01 Avatar answered May 05 '26 14:05

arashi01



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!