Name

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.

  • CFLAGS. Call Scilab needs to have access to the headers of Scilab core and call Scilab module.

    • Linux/Unix/MacOSX:

      • In the binary version of Scilab, CFLAGS must be set to /path/to/scilab/include/scilab/core/ and /path/to/scilab/include/scilab/call_scilab/

      • In the source tree of Scilab, CFLAGS must be set to /path/to/scilab/modules/core/includes/ and /path/to/scilab/modules/call_scilab/includes/

    • Windows

  • LD_LIBRARY_PATH - Paths to libscilab.so and libjavasci.so (or .dll, .jnilib...)

    • Linux/Unix/MacOSX:

      • In the binary version of Scilab, SCI will point to /path/to/scilab/lib/scilab/

      • In the source tree of Scilab, SCI will point to the root of the source tree /path/to/scilab/modules/call_scilab/.libs/ and /path/to/scilab/.libs/

  • LDFLAGS - The name of the library to link against

    • Linux/Unix/MacOSX: It is only mandatory to link against scilab. This should include the other libraries.

 
# 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:

  • SCI - Path to Scilab files

    • Linux/Unix/MacOSX:

      • In the binary version of Scilab, SCI will point to /path/to/scilab/share/scilab/

      • In the source tree of Scilab, SCI will point to the root of the source tree /path/to/scilab/source/tree/

    • Windows:

  • LD_LIBRARY_PATH - Paths to libscilab.so and libjavasci.so (or .dll, .jnilib...)

    • Linux/Unix/MacOSX:

      • In the binary version of Scilab, SCI will point to /path/to/scilab/lib/scilab/

      • In the source tree of Scilab, SCI will point to the root of the source tree /path/to/scilab/modules/javasci/.libs/ and /path/to/scilab/.libs/

  • LD_LIBRARY_PATH (Java) - Paths to Java native libraries (libjava.so, libjvm.so, libhpi.so)... It is usually provided by the operating system or by Scilab distribution. Please note that won't be necessary in Scilab 5.2

    • Linux/Unix:

      • JAVA_HOME/jre/lib/<arch>/, JAVA_HOME/jre/lib/<arch>/server, JAVA_HOME/jre/lib/<arch>/native_threads/ (<arch> can be i386, etc...)

    • Mac OS X:

    • Windows

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

  • SCI_DISABLE_TK=1 Disables Tk (Tcl's GUI)

  • SCI_JAVA_ENABLE_HEADLESS=1 Launch Java in headless mode (no AWT/Swing)

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 to Scilab binary>
$ export LD_LIBRARY_PATH=$SCI/lib/scilab/

# Don't forget to update i386 to whatever is necessary
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/jvm/java-6-openjdk//jre/lib/i386/:/usr/lib/jvm/java-6-openjdk//jre/lib/i386/server/
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/jvm/java-6-openjdk//jre/lib/i386/native_threads/
$ export SCI=/path/to/scilab/
$ ./myExample
!sample  for the help  !
 
  - 42.    42.  
 

See Also

api Scilab,call_scilab, StartScilab, SendScilabJob, SendScilabJobs, Double Management, Boolean Management, Complex Management, String Management

Authors

Allan Cornet

Sylvestre Ledru