File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
examples/call_v_from_ruby Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 77
88require 'ffi'
99
10+ # extension for shared libraries varies by platform - see vlib/dl/dl.v
11+ # get_shared_library_extension()
12+ def shared_library_extension
13+ if Gem . win_platform?
14+ '.dll'
15+ elsif RUBY_PLATFORM =~ /darwin/ # MacOS
16+ '.dylib'
17+ else
18+ '.so'
19+ end
20+ end
21+
1022module Lib
1123 extend FFI ::Library
1224
13- ffi_lib File . join ( File . dirname ( __FILE__ ) , 'test.so' )
25+ begin
26+ ffi_lib File . join ( File . dirname ( __FILE__ ) , 'test' + shared_library_extension )
27+ rescue LoadError
28+ abort ( "No shared library test#{ shared_library_extension } found. Check examples/call_v_from_ruby/README.md" )
29+ end
1430
1531 attach_function :square , [ :int ] , :int
1632 attach_function :sqrt_of_sum_of_squares , [ :double , :double ] , :double
You can’t perform that action at this time.
0 commit comments