Created
December 4, 2015 13:34
-
-
Save asterite/28ec169fb686f2e53e7d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
libmylib.so: mylib.cr | |
crystal mylib.cr --link-flags "-dynamic -bundle -Wl,-undefined,dynamic_lookup" -o libmylib.dylib | |
.PHONY: clean run | |
clean: | |
rm *.dylib | |
run: libmylib.dylib | |
ruby mylib.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun add(a : Int32, b : Int32) : Int32 | |
a + b | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fiddle' | |
require 'fiddle/import' | |
module MyLib | |
extend Fiddle::Importer | |
dlload 'libmylib.dylib' | |
extern 'int add(int, int)' | |
end | |
puts MyLib.add(11, 31) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment