<< call_scilab call_scilab API (Scilab engine) Complex management >>

Scilab Help >> call_scilab API (Scilab engine) > Compile and run with Call Scilab

Compile and run with Call Scilab

How to compile a native application based on or using Scilab

Compilation

To compile a native code based on Call Scilab, it is necessary to define some arguments, variables and paths.

The following example is a Makefile to build against Scilab binary

# A sample Makefile building a C code using Call Scilab using Scilab binary
PATH_SCILAB = /path/to/scilab/
# Note that PATH_SCILAB can be /usr/ is using a packaged version of Scilab.
SCILAB_CFLAGS = -I$(PATH_SCILAB)/include/scilab/
SCILAB_LDFLAGS = -lscilab
PATH_TO_LIB_SCILAB = $(PATH_SCILAB)/lib/scilab/
PATH_TO_LIB_CALL_SCILAB = $(PATH_SCILAB)/lib/scilab/

all: simple_call_scilab.c
    export LD_LIBRARY_PATH=$(PATH_TO_LIB_SCILAB):$(PATH_TO_LIB_CALL_SCILAB)
    gcc -o myExample $(SCILAB_LDFLAGS) -L$(PATH_TO_LIB_SCILAB) -L$(PATH_TO_LIB_CALL_SCILAB) $(SCILAB_CFLAGS) simple_call_scilab.c

The following example is a Makefile to build against Scilab source tree

# A sample Makefile building a C code using Call Scilab using Scilab built in it source tree.
PATH_SCILAB = /path/to/scilab/sources/
SCILAB_CFLAGS = -I$(PATH_SCILAB)/modules/core/includes/ -I$(PATH_SCILAB)/modules/call_scilab/includes/
SCILAB_LDFLAGS = -lscilab
PATH_TO_LIB_SCILAB = $(PATH_SCILAB)/modules/.libs/
PATH_TO_LIB_CALL_SCILAB = $(PATH_SCILAB)/modules/call_scilab/.libs/

all: simple_call_scilab.c
    export LD_LIBRARY_PATH=$(PATH_TO_LIB_SCILAB):$(PATH_TO_LIB_CALL_SCILAB)
    gcc -o myExample $(SCILAB_LDFLAGS) -L$(PATH_TO_LIB_SCILAB) -L$(PATH_TO_LIB_CALL_SCILAB) $(SCILAB_CFLAGS) simple_call_scilab.c

Running

To run an application based on Call Scilab, there are a few other things to set up.

Some global variables must me set:

Note that two environment variables are taken in account for specific needs:

Examples

# Serie of declarations to execute my binary.

# With a Scilab source tree:
$ SCI=<path to Scilab source tree>
$ export LD_LIBRARY_PATH=$SCI/modules/.libs/:$SCI/modules/call_scilab/.libs/:$SCI/modules/api_scilab/.libs

# With a Scilab binary:
$ SCI_PATH=<path to Scilab binary>
$ export LD_LIBRARY_PATH=$SCI_PATH/lib/scilab/

# Set the path to Java Virtual Machine library; This is mandatory for graphics features
# Don't forget to update arch (i386) and paths to whatever is necessary
$ export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/i386/:$JAVA_HOME/jre/lib/i386/server/
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/i386/native_threads/
$ export SCI=/path/to/scilab/
$ ./myExample
!sample  for the help  !

  - 42.    42.

See also


Report an issue
<< call_scilab call_scilab API (Scilab engine) Complex management >>