Compiling and linking a C user function
lib = SUN_Clink(names, files, options)
names | a string matrix giving the entry point names which are to be linked |
files | string matrix giving source files needed for shared library creation |
options | a sequence of optional named arguments |
lib | the full path of the generated library |
This function aims to simplify the compilation and dynamic link of SUNDIALS entrypoints. It is a wrapper to
ilib_for_link with the adequate compiler flags and allows to immediately
do the dynamic link or copy the DLL and the loading script in the current directory. In that case the default name
of the library is defined with the following Scilab code: "lib" + names(1) + getdynlibext()
The options are the following:
loadername,libname,ldflags,cflags,cc | These options have the same meaning as the corresponding formal parameters of ilib_for_link. For example to change the loader name, and the compiler, add the options like this
|
load | A boolean value. Set this option to %t if you want to load the library just after compilation. In that case the library and the loading script remain in TMPDIR. If set to %f (the default) the library is not loaded but moved in the current directory with the loading script. |
mputl([ "#include <nvector/nvector_serial.h>" "int sunRhs(realtype t, N_Vector N_VectorY, N_Vector N_VectorYd, void *user_data)" "{" "double *y = NV_DATA_S(N_VectorY);" "double *ydot = NV_DATA_S(N_VectorYd);" "ydot[0] = y[1];" "ydot[1] = (1-y[0]*y[0])*y[1]-y[0];" "return 0;" "}" ],"code.c"); SUN_Clink("sunRhs", "code.c",load = %t); [t,y] = cvode("sunRhs",[0 1],[0;2]) | ![]() | ![]() |