Call a function in a shared library: Difference between revisions

→‎{{header|Crystal}}: add crystal implementation
m (→‎{{header|REXX}}: elided a blank line.)
(→‎{{header|Crystal}}: add crystal implementation)
Line 274:
:pointer)
#.(SB-SYS:INT-SAP #X00650FD0)</lang>
 
=={{header|Crystal}}==
 
<lang ruby>libm = LibC.dlopen("libm.so", LibC::RTLD_LAZY)
libm.value.not_nil!
 
sqrtptr = LibC.dlsym(libm, "sqrt")
sqrtptr.value.not_nil!
 
sqrtproc = Proc(Float64, Float64).new sqrtptr, Pointer(Void).null
puts "the sqrt of 4 is #{sqrtproc.call(4.0)}"
 
LibC.dlclose(libm)</lang>
 
=={{header|D}}==
Anonymous user