William,

I finally got SWIG+Scilab building on xubuntu and OSX, but cannot get anything, even the simple examples, to work.  Here's where I stand:

On OSX I have a build script that looks something like (same thing on xubuntu, just apt-get instead of brew and different paths)

brew install autoconf automake pcre
git clone https://github.com/swig/swig -b gsoc2012-scilab swig-scilab
cd swig-scilab
sh autogen.sh
./configure --with-scilab-inc=/Applications/scilab-5.4.1/Contents/MacOS/include --with-scilab=/Applications/scilab-5.4.1/Contents/MacOS/bin/scilab-cli --prefix=/Users/Ian/Desktop/swig-bin
make
make install

Once I get swig+scilab built, if I do cd Examples/scilab/simple, and I run make, I get a few errors about the stack functions:

ilib_compile: An error occurred during the compilation:
In file included from example_wrap.c:759:0:
/home/ian/Desktop/scilab-5.4.1/share/scilab/../../include/scilab/stack-c.h:19:6: error: #error Using stack-c.h is deprecated. Please use api_scilab instead (try 'help api_scilab'). Note the stack-c.h API will be removed after Scilab 6.0. You can define __USE_DEPRECATED_STACK_FUNCTIONS__ to bypass this error.
     #error Using stack-c.h is deprecated. Please use api_scilab instead (try 'help api_scilab'). Note the stack-c.h API will be removed after Scilab 6.0. You can define __USE_DEPRECATED_STACK_FUNCTIONS__ to bypass this error.
      ^

which I can resolve by doing something like

swig -scilab -addcflag "-D__USE_DEPRECATED_STACK_FUNCTIONS__" *.i

which is not documented anywhere.

Running exec builder.sce does appear to work, it makes the .so file, and when I run nm libexamplelib.so I see all the necessary symbols.  So far so good.

But then when I try to run the file runme.sci, I get

ian@ian-VirtualBox:~/Code/swig-scilab/Examples/scilab/simple$ ~/Desktop/scilab-5.4.1/bin/scilab-cli -f runme.sci
Scilab 5.4.1 (Mar 29 2013, 16:52:15)
addinter(libexamplelib_path + 'libexamplelib' + getdynlibext(), 'libexamplelib', list_functions);
                                                                                                 !--error 236
addinter: The shared archive was not loaded: /home/ian/Code/swig-scilab/Examples/scilab/simple/libexamplelib.so: undefined symbol: Foo
at line      18 of exec file called by :   
exec loader.sce;
at line       3 of exec file called by :   
exec('SCI/etc/scilab.start',-1);;exec('runme.sci',-1)


which doesn't make sense because the symbol Foo is definitely exported in the .so.  A snip from the nm libexamplelib.so:

00002b42 T example_Init
00002d34 T _fini
00005174 b fname
         U Foo
00002647 T Foo_get
000026f5 T Foo_set
00000dc0 t frame_dummy
00004eec t __frame_dummy_init_array_entry
00003960 r __FRAME_END__
         U free@@GLIBC_2.0
         U gcd


I think I am at the limits of my debugging abilities for the moment.  Once I get this working I really want to get it working on OSX and windows.  I'd be happy to contribute to the wiki my experiences if that would be useful.

Ian


On Mon, Oct 21, 2013 at 8:16 AM, William S Fulton <wsf@fultondesigns.co.uk> wrote:
On 18/10/13 17:33, Ian Bell wrote:
I have an open-source thermophysical property library (like REFPROP) that I
am trying to wrap using SWIG for scilab.  I'm pretty experienced with the
use of SWIG for C#, python, Java, Octave, etc.

For the life of me I cannot get swig to build with this mysterious comment


./configure --with-scilab=<path_scilab_startup_script>

I am a newcomer to scilab (love the idea as there is a lot that is
appealing about MATLAB apart from the ridiculous price) but an experienced
programmer. What does <path_scilab_startup_script> refer to?

Are you looking at the correct location? https://github.com/swig/swig/commits/gsoc2012-scilab is what you should be using,

$ ./configure --help | grep -i sci
  --without-scilab        Disable Scilab
  --with-scilab=path      Set location of Scilab executable
  --with-scilabincl=path  Set location of Scilab include directory


I would like to support linux, OSX and windows.

I think it is being developed under Linux, the testing we do is focused on Linux, using Travis.


Will this work on OSX?  Does anyone have binaries for windows?  The build
process for swig on windows is truly atrocious.

It shouldn't take much effort to support other operating systems as SWIG aims to generate platform neutral code. If I make the Windows binaries for you, perhaps you could port the examples to Windows? At a minimum, the class and simple examples under the Examples\scilab directory just require a Visual Studio project file. Some usage instructions to Doc\Manual\Windows.html would be needed for these examples. If you are not aware, Simon is working hard on getting Scilab ready for our next release - 3.0.0, and these patches for Windows would be much appreciated.

OSX should work the same way as Linux, it is just a matter of working out how to install Scilab for SWIG's configure to automatically detect it. Some configure.ac changes might be required. Brew seems to be the preferred approach to installing open source tools. Does anyone have Scilab working when installed using Brew?

William