Skip to content
A minimal Scala Native example that shows how to call C functions from Scala
Branch: master
Clone or download
Latest commit 5392530 Nov 12, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project Updated to work with the latest version of Scala Native Nov 12, 2017
src/main Renamed the C function Nov 12, 2017
.gitignore
LICENSE Inital commit Dec 29, 2016
README.md
build.sbt Updated to work with the latest version of Scala Native Nov 12, 2017
makefile Inital commit Dec 29, 2016

README.md

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

You can’t perform that action at this time.