Skip to content

Instantly share code, notes, and snippets.

@kjunichi
Last active July 5, 2016 04:19
Show Gist options
  • Save kjunichi/6ca1f2b48f908c5867bf74686ceb2b03 to your computer and use it in GitHub Desktop.
Save kjunichi/6ca1f2b48f908c5867bf74686ceb2b03 to your computer and use it in GitHub Desktop.
/Applications/Julia-0.4.5.app/Contents/Resources/julia/bin/julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.5 (2016-03-18 00:58 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-apple-darwin13.4.0

julia> t = ccall( (:mrb_open, "libmruby"), Ptr{UInt8}, ())
Ptr{UInt8} @0x00007fe715987700

julia> r = ccall( (:mrb_load_string, "libmruby"), Void, (t,"puts 'Hello,World!'"))
ERROR: error compiling anonymous: ccall: wrong number of arguments to C function

julia> r = ccall( (:mrb_load_string, "libmruby"), Void, (Ptr{Uint8},CString),(t,"puts 'Hello,World!'"))
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
  likely near no file:0
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
  likely near no file:0
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
  likely near no file:0
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
  likely near no file:0
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
  likely near no file:0
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
  likely near no file:0
ERROR: error interpreting ccall argument tuple
 in anonymous at no file

julia> r = ccall( (:mrb_load_string, "libmruby"), Void, (Ptr{Uint8},CString),t,"puts 'Hello,World!'")
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
  likely near no file:0
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
  likely near no file:0
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
  likely near no file:0
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
  likely near no file:0
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
  likely near no file:0
WARNING: Base.Uint8 is deprecated, use UInt8 instead.
  likely near no file:0
ERROR: UndefVarError: CString not defined
 in anonymous at no file

julia> r = ccall( (:mrb_load_string, "libmruby"), Void, (Ptr{UInt8},CString),t,"puts 'Hello,World!'")
ERROR: UndefVarError: CString not defined
 in anonymous at no file

julia> r = ccall( (:mrb_load_string, "libmruby"), Void, (Ptr{UInt8},Cstring),t,"puts 'Hello,World!'")
Hello,World!

julia> r = ccall( (:mrb_load_string, "libmruby"), Void, (Ptr{UInt8},Cstring),t,"puts 'Hello,World!'")
Hello,World!

julia> 
libtool -dynamic -multiply_defined suppress -o libmruby.dylib mruby/build/host/lib/libmruby.a -L/Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/ -ljulia -undefined dynamic_lookup -macosx_version_min 10.11

install_name_tool -change '@rpath/libjulia.dylib' '/Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/libjulia.dylib' libmruby.dylib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment