dlcall
C or Fortran Foreign function call.
📝Syntax
[x1, ... , xN] = dlcall(dlsym_handle, arg1, ..., argN)
📥Input Arguments
Parameter Description
dlsym_handle a dlsym handle.
arg1, ..., argN input arguments.
📤Output Arguments
Parameter Description
[x1, ... , xN] output values.
📄Description

dlcall calls an external C or Fortran function loaded from an shared library.

dlcall validates input argument types before calling based on dlsym handle definition.

💡Examples
lib = dlopen([modulepath('nelson', 'builtin'), '/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.m']);
Call fortran DASUM (blas) function
run([modulepath('dynamic_link'), '/examples/call_fortran.m']);
🔗See Also
dlsymC/Nelson equivalent data types
🕔Version History
Version Description
1.0.0 initial version
Edit this page on GitHub