I would like to use Scala Native for my backend server to run some code, which are writen in C.
But when I enabled the scala native plugin in the build.sbt, I got errors during nativeLink.
my build.sbt looks like this:
lazy val akkaHttpVersion = "10.6.0"
lazy val akkaVersion = "2.9.0"
resolvers += "Akka library repository".at("https://repo.akka.io/maven")
enablePlugins(
JavaAppPackaging,
DockerPlugin)
fork := true
dockerBaseImage := "adoptopenjdk:11-jre-hotspot"
dockerExposedPorts ++= Seq(8080, 8080)
lazy val root = (project in file(".")).
settings(
inThisBuild(List(
organization := "fev.io",
scalaVersion := "2.13.12"
)),
name := "miniuptane",
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion,
"com.typesafe.akka" %% "akka-actor-typed" % akkaVersion,
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
"ch.qos.logback" % "logback-classic" % "1.2.11",
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % Test,
"com.typesafe.akka" %% "akka-actor-testkit-typed" % akkaVersion % Test,
"org.scalatest" %% "scalatest" % "3.2.12" % Test,
"org.scala-lang" %% "toolkit" % "0.1.7",
"com.typesafe.slick" %% "slick" % "3.4.1",
"com.typesafe.slick" %% "slick-hikaricp" % "3.4.1",
"mysql" % "mysql-connector-java" % "5.1.34"
)
)
enablePlugins(ScalaNativePlugin)
import scala.scalanative.build._
nativeConfig ~= {
_.withLTO(LTO.thin)
.withMode(Mode.releaseFast)
.withGC(GC.commix)
}
compile of scala code has no problem. But when I run in sbt, the nativeLink returns following error
Unknown type akka.http.scaladsl.marshalling.PredefinedToResponseMarshallers, referenced from:
…
(Compile / nativeLink) Unreachable symbols found after classloading run. It can happen when using dependencies not cross-compiled for Scala Native or not yet ported JDK definitions.
this error is only one example, I got a lot of similar errors. it seems like the akkt http cannot run if the scala native plugin enabled. if it is not enabled, there is no such error
user25511590 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.