Skip to content

Instantly share code, notes, and snippets.

@davidkellis
Last active December 10, 2018 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidkellis/f40588787a354aa7d44c4dec4c52ad50 to your computer and use it in GitHub Desktop.
Save davidkellis/f40588787a354aa7d44c4dec4c52ad50 to your computer and use it in GitHub Desktop.
bar project in Crystal (that calls the foo library, implemented in Rust - https://gist.github.com/davidkellis/78bd7c65f31539b183f1b60c43339ff9)

How to run:

$ crystal run src/bar.cr
hello from crystal
Just called a Rust function from C!
name: bar
version: 0.1.0
authors:
- davidkellis <davidkellis@gmail.com>
targets:
bar:
main: src/bar.cr
crystal: 0.26.1
license: MIT
# TODO: Write documentation for `Bar`
module Bar
VERSION = "0.1.0"
end
@[Link(ldflags: "#{__DIR__}/../../foo/target/debug/libfoo.dylib")]
lib Foo
fun call_from_c()
end
def main
puts "hello from crystal"
Foo.call_from_c
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment