Can I create a static library using ScalaNative on linux?

99 views Asked by At

I've written some code I'd like to share across a couple of ScalaNative command line tools I'm working on.

Can I generate a library (preferably static) that I can share between multiple ScalaNative console applications?

Thank you!

1

There are 1 answers

1
Lorenzo Gabriele On BEST ANSWER

Starting from Scala Native 0.4.8 it can generate dynamic and static libraries.

What you need to do is add the following to your build.sbt file.

To generate a dynamic library:

import scala.scalanative.build.BuildTarget

nativeConfig ~= {
  _.withBuildTarget(BuildTarget.libraryDynamic)
}

To generate a static library:

import scala.scalanative.build.BuildTarget

nativeConfig ~= {
  _.withBuildTarget(BuildTarget.libraryStatic)
}