Jump to content

Call a function in a shared library: Difference between revisions

no edit summary
(Added Perl example)
No edit summary
Line 287:
 
<pre>500</pre>
 
=={{header|Dart}}==
 
add.c
<lang c>
int add(int num1, int num2) {
return num1 + num2;
}
</lang>
 
Dart code
<lang javascript>import 'dart:ffi'
show DynamicLibrary, NativeFunction, Int32;
 
main(){
final lib = DynamicLibrary.open('add.dylib'); // Load library
final int Function(int num1,int num2) add = lib // Write Dart function binding
.lookup<NativeFunction<Int32 Function( Int32, Int32 )>>('add') // Lookup function in library
.asFunction(); // convert to Dart Function
 
print( add( 1, 2 ) );
}
</lang>
 
 
=={{header|Delphi}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.