Skip to content

A minimal Scala Native example that shows how to call C functions from Scala

License

Notifications You must be signed in to change notification settings

olofwalker/scala-native-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scala-native-example

A minimal Scala Native example that calls a C function (https://github.com/scala-native/scala-native)

About the example

  • The project contains two source code files, main.scala and stub.c
  • Main.scala will call a function in stub.c
  • The stub.c function writeFile called from Scala will write a file in the current working directory

About the build process

  • The scala native plugin is added in the project/plugins.sbt file
  • build.sbt runs the makefile, producing the shared library in the \target directory
  • A custom library path is added to nativeLinkingOptions so the stub library can be found
  • Compile & run with sbt run
  • The resulting native executable can be found in target/scala-2.11

Requirements

  • 64 bit Linux based OS

Dependencies

Fedora:

sudo dnf install clang-devel libgc-devel llvm-devel libunwind-devel

About

A minimal Scala Native example that shows how to call C functions from Scala

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published