Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2024.0.0 - Português


SUN_Clink

Compiling and linking a C user function

Syntax

lib = SUN_Clink(names, files, options)

Arguments

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

Description

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

SUN_Clink(names, files, loader="loader.sce", cc="clang")

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.

Example

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])

See also

  • arkode — SUNDIALS ordinary differential equation additive Runge-Kutta solver
  • cvode — SUNDIALS ordinary differential equation solver
  • ida — SUNDIALS differential-algebraic equation solver
  • kinsol — SUNDIALS general-purpose nonlinear system solver
  • User functions — Coding user functions used by SUNDIALS solvers
  • ilib_for_link — utility for shared library management with link
Report an issue
<< Options, features and user functions Options, features and user functions Callback >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Oct 24 14:35:23 CEST 2023