<< dlopen | dynamic link | dlsym_delete >> |
f = dlsym(lib, symbol_name, return_type, params_types) |
a dllib handle.
a string: symbol to load.
a string: return type of the C/Fortran function.
a cell of strings: arguments using a special syntax with differents data types.
a dlsym handle.
dlsym retrieves the address of an exported function as an dlsym handle.
Warning: Uses wrong datatype definitions a foreign function can terminate unexpectedly.
lib = dlopen([modulepath(nelsonroot(),'dynamic_link','bin'), '/libnlsDynamic_link', getdynlibext()]);
V = double([1 2;3 4]);
// C prototype:
// int dynlibTestMultiplyDoubleArrayWithReturn(double *x, int size)
f = dlsym(lib, 'dynlibTestMultiplyDoubleArrayWithReturn', 'int32', {'doublePtr', 'int32'});
[r1, r2] = dlcall(f, V, int32(numel(V)))
delete(f);
delete(lib);
Call C getpid function
run([modulepath('dynamic_link'), '/examples/call_c.nls']);
Call fortran DASUM (blas) function
run([modulepath('dynamic_link'), '/examples/call_fortran.nls']);
dlcall, C/Nelson equivalent data types.
Version | Description |
---|---|
1.0.0 | initial version |
Allan CORNET