Contents

  1. Compiling Scilab 5.X and 6.X under Mac OS X
  2. Installation of necessary dependencies
    1. Base tools
    2. Compilation tools
    3. Source control tools
    4. Java
    5. Libraries needed by Scilab
  3. Getting the Scilab code and running the build
    1. Get the source
    2. Select the right branch
    3. Run the build
    4. Packaging (Mac OS X style)
  4. FAQ: Mac OS X issues
    1. Cannot locate tools.jar
    2. Since Scilab 5.3, only 64 bits is supported. Why that ?
    3. What is done to ensure the 64 bits build ?
    4. I have installed all Scilab dependencies through fink 32 bits and it fails
    5. The configure fails on the detection of libxml2
    6. Trying to install a package through fink with a Mac OS X 10.5, I get an error about xcode
    7. Scilab 5.3.0 beta 5 crashes on the startup
    8. JVM launched in a dedicated thread
    9. G77 troubleshooting
    10. Symbol not exported
    11. Running ant, I get ''Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher''
    12. Running ant, I get ''XML parser factory has not been configured correctly: Provider -n gnu.xml.aelfred2.JAXPFactory not found''
    13. If Scilab.app does not start
    14. I did some changes in the Info.plist of Scilab but my changes are not taken in account
    15. Installing gfortran using fink I get ''Can't resolve dependency "fink (>= 0.28.0)" for package "gettext-tools-0.14.5-4"''
    16. How Java paths are handled under Mac OS X ?
    17. While building, I get 'ld: codegen problem, can't use rel32 to external symbol'
    18. Java is failing to build on a basic class
    19. On startup, Scilab complains about the JNI version
    20. Trouble with pkg-config and matio
    21. Wrong version of libintl / conflict between versions
  5. Development aspects
    1. Handle Mac OS X mouse
    2. Shortcut with Mac OS X
    3. Fink 64 bits
    4. I can't get matio with fink
    5. strace equivalent
    6. Error in the creation of the Java VM: JNI version error
    7. Howto to get information about library being loader by the linker
    8. Howto remove some archs from a dylib library
    9. Howto change the hardcoded paths in a dylib library
    10. Howto change the id of a dylib library
    11. Debugging on MacOS Sierra
    12. Running Scilab 6.0.1 on MacOS Mojave

Compiling Scilab 5.X and 6.X under Mac OS X

The instructions below apply to both 5.x and 6.x. They may not be complete, please feel free to add comments at the end.

Installation of necessary dependencies

Base tools

Compilation tools

Source control tools

Java

A JDK is needed, as a lot of Scilab's code is in Java. For Scilab 5.5 and previous, the JDK is 1.6, which is present on Mac by default.

For Scilab 6, the JDK must be 1.8, and installed from Oracle's site at http://www.oracle.com/technetwork/java/javase/downloads/index.html .

You will then need to provide the build with the JDK's location. The easiest is to run:

 export JAVA_HOME=`/usr/libexec/java_home -v '1.8*'`

Libraries needed by Scilab

See Dependencies of Scilab 5.X for details. All dependencies are available as Fink packages.

In particular:

But that list is probably not complete. A complete list of library dependencies that worked recently is:

sudo fink install suitesparse
sudo fink install fftw3
sudo fink install libmatio2
sudo fink install libmatio2-shlibs
sudo fink install hdf5.8
sudo fink install hdf5.8-shlibs
sudo fink install libpcre1
sudo fink install ant

sudo fink install gettext-bin-0.19.3-1
sudo fink install gettext-tools-0.19.3-1
sudo fink install arpack-ng-3.1.5-3
sudo fink install pkgconfig-0.28-1
sudo fink install libcurl4-7.42.0-1+10.8
sudo fink install libmatio2-1.5.2-2

Getting the Scilab code and running the build

Get the source

(note that the branch macosx has been merged with the master and is not used)

Select the right branch

Run the build

cd scilab

# Use Fink to get the right tools & libraries
. /sw/bin/init.sh

# for Scilab 6 (branch master) don't forget to use java 6 (see above)
export JAVA_HOME=`/usr/libexec/java_home -v '1.8*'`
# (alternatively, adding this option to the ./configure command:
#  --with-jdk=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home
# should do the job)

# Some useful options for the command below:
# - CC=gcc-5 CXX=g++-5 if you want to use GCC because Apple has the great idea of shipping a version of clang as /usr/bin/gcc!
      so specifying a version number will ensure that the Gnu gcc (in /sw/bin), not clang, is used.
# - CFLAGS=-fdiagnostics-color=always CXXFLAGS=-fdiagnostics-color=always will color the output (warnings/errors/etc)
# - --without-tk because Scilab includes tcl/tk by default, and (at least on Scilab 5.5) 
#     there is an incompatibility between tcl/tk's threading model and the MacOS's
#    (probably an incompatibility of TK with the Apple Java VM, or more generally with Cocoa - to investigate)
# - --with-eigen_include=`pwd`/lib/Eigen/includes to specify where to find the eigen libraries (added as third-party)
# - If you don't have ocaml, you can add '--without-modelica'

# The real thing!
./configure --without-openmp --without-tk --with-eigen_include=`pwd`/lib/Eigen/includes && make

If you used gcc-5 or -4 and are having an error in an Apple header (located in /usr/include/ or in /System/Library/), please edit modules/console/Makefile & modules/localization/Makefile to replace occurrences of "gcc-5" (/"gcc-4") by "clang". This is only a workaround at the moment, until one day Apple make their headers gcc-compatible.

At Scilab startup on Yosemite/El Capitan, if you have an error "JavaVM: Failed to load JVM: /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/libserver.dylib", you need to create a symbolic link from "libserver" to "libjvm":

In the line above, you may replace both "jdk1.8.0_102" with your installed Java version, found in "/Library/Java/JavaVirtualMachines/jdk1.8.*".

Packaging (Mac OS X style)

That's all.

FAQ: Mac OS X issues

Cannot locate tools.jar

Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/lib/tools.jar
Buildfile: build.xml

gcj is not supported by Scilab. Please try with the OpenJDK 6 or 7.

Since Scilab 5.3, only 64 bits is supported. Why that ?

Because Apple does not really care about their Mac OS X previous releases.

To have best performances and because it fixes many bugs, Scilab (since version 5.3) depends on a Java Virtual Machine (JVM) 1.6. This version of the JVM is only available as 64 bits (not 32 bits or PPC) and since Scilab needs to link against libjvm.dylib, Scilab needs also to be 64 bits ready.

What is done to ensure the 64 bits build ?

When a user/developer is building Scilab under Mac OS X, in the configure, we add the argument -arch x86_64 to gcc and g++ to make sure that the libraries are 64 bits.

I have installed all Scilab dependencies through fink 32 bits and it fails

You have to install fink running in 64bit-only mode. Basically, you have to do:

rm -rf /sw
path/to/fink/bootstrap
[...]
Your hardware is a 64bit-compatible intel processor, so you have the option of running Fink in 64bit-only mode.  This
is not recommended for most users, since many more packages are available for the default mode (which is mostly 32bit
but includes some 64bit packages).  Which mode would you like to use?

(1)     Default (mostly 32bit)
(2)     64bit-only

Choose a mode: [1] 2
[...]
# Select the 64-bit only mode

The configure fails on the detection of libxml2

The error:

configure: error: libxml2 : library missing. (Cannot find symbol xmlReaderForFile). Check if libxml2 is installed and if the version is correct

In the configure, linking against libxml2 is one of the first test on third party libraries. Usually, if the library is available, that means that the library is not available in x86_64 mode. For example, with fink:

file $(dpkg -L libxml2-shlibs|grep dylib)
/sw/lib/libxml2.2.6.32.dylib: Mach-O dynamically linked shared library i386
# should be
/sw/lib/libxml2.2.6.32.dylib: Mach-O dynamically linked shared library x86_64

Trying to install a package through fink with a Mac OS X 10.5, I get an error about xcode

Can't resolve dependency "xcode (>= 3.1.2)" for package "gcc44-4.4.1-1000" (no matching packages/versions found)

Download a more recent version of Xcode. For example from:

Scilab 5.3.0 beta 5 crashes on the startup

If the error message is the following:

  Symbol not found: _libiconv_open
  Referenced from: /Applications/scilab-5.3.0-beta-5.app/Contents/MacOS/lib/thirdparty//libintl.3.dylib
  Expected in: /Applications/scilab-5.3.0-beta-5.app/Contents/MacOS/lib/thirdparty//libiconv.2.dylib

try a nightly build or a more recent version. See bug #8460 for more information

JVM launched in a dedicated thread

Under Mac OS X, launching a JVM from a C code requires the dedicated thread Example. This is done in modules/shell/src/c/others/mainscic.c (see #ifdef APPLE)

G77 troubleshooting

Symbol not exported

Mac OS X linker handles library's symbols differently from GNU/Linux. See bug 3740 for more information.

Running ant, I get ''Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher''

export ANT_HOME=/sw/lib/ant/

should fix your issue.

Running ant, I get ''XML parser factory has not been configured correctly: Provider -n gnu.xml.aelfred2.JAXPFactory not found''

Usually,

export CLASSPATH=/sw/lib/ant/lib/xercesImpl.jar

fixes the problem.

If Scilab.app does not start

Have a look to /var/log/system.log to see if there are any error messages.

I did some changes in the Info.plist of Scilab but my changes are not taken in account

Try to touch the directory: touch Scilab.app it should flush the Info.plist.

Installing gfortran using fink I get ''Can't resolve dependency "fink (>= 0.28.0)" for package "gettext-tools-0.14.5-4"''

Try fink index -f

How Java paths are handled under Mac OS X ?

Read Important Java Directories on Mac OS X

While building, I get 'ld: codegen problem, can't use rel32 to external symbol'

We had this issue once. It was due to a file built but unused. We just removed the symbol and it fixed the issue. Don't ask why!

Java is failing to build on a basic class

 [javac] /Users/sylvestreledru/git/scilab/scilab/modules/gui/src/java/org/scilab/modules/gui/utils/WebBrowser.java:15: cannot find symbol
    [javac] symbol  : class Desktop
    [javac] location: package java.awt
    [javac] import java.awt.Desktop;

This is usually caused because, for some reasons, the Java used by an version 1.5 while it should be 1.7. The following command should fix it:

export JAVA_HOME=`/usr/libexec/java_home`

On startup, Scilab complains about the JNI version

This occurs in some cases when Scilab is built with the option -framework JavaVM. This option is linking Scilab against the library /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM which is Java 1.5. Since Scilab is built with Java 1.6, it conflicts on the JNI version.

Erreur lors de la création de la Machine Virtuelle Java : Erreur de version JNI

Trouble with pkg-config and matio

if you have not installed pkg-config (try in command line 'which pkg-config'), install it:

Wrong version of libintl / conflict between versions

dyld: Library not loaded: /sw/lib/libintl.8.dylib
Referenced from: /sw/bin/tar
Reason: Incompatible library version: tar requires version 10.0.0 or later, but libintl.8.dylib provides version 9.0.0

This probably comes from the update of fink, in case you use it. The solution is to copy /sw/lib/libintl.x.x.x.dylib (latest version of the library) to scilab.app/Content/MacOSX/lib/thirdparty/. At startup, the PATH order is changed to /sw/bin;/usr/bin, so when looking for tar, it goes straight to sw. fink (which maintains the sw folder) being updated, the version between the libintl that /sw/bin/tar uses and the one packaged in Scilab differ, and we can't load an already loaded library. Tar doesn't see its version of libintl, so refuses to load.

Development aspects

Handle Mac OS X mouse

http://gitweb.scilab.org/?p=scilab;a=commitdiff;h=58b37462d2637ed92bb5452cc0d49e63d3e5e681

Shortcut with Mac OS X

http://gitweb.scilab.org/?p=scilab;a=commitdiff;h=aa8098d9b3e8dbf316dc5226c542134823b56416

Fink 64 bits

http://sage.ucsc.edu/~wgscott/xtal/wiki/index.php/64-bit_Fink_for_10.5_and_10.6

I can't get matio with fink

In the file /sw/etc/fink.conf, add stable/crypto unstable/main unstable/crypto to the Trees line :

Trees: local/main stable/main stable/crypto unstable/main unstable/crypto

strace equivalent

sudo dtruss -f <program>
sudo dtruss -f <program> 2> trace.log

Error in the creation of the Java VM: JNI version error

under 10.5, you may have this error. launch java preferences, uncheck java 10.5 and relaunch scilab.

Howto to get information about library being loader by the linker

DYLD_PRINT_LIBRARIES=1 ./bin/scilab-cli

will display which libraries are being loaded.

Howto remove some archs from a dylib library

lipo -remove <arch>

http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/lipo.1.html

Howto change the hardcoded paths in a dylib library

 install_name_tool -change /sw/lib/libintl.3.dylib @executable_path/../lib/thirdparty/libintl.3.dylib lib/scilab/libscilab.dylib

http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/install_name_tool.1.html

Howto change the id of a dylib library

install_name_tool -id @executable_path/../lib/thirdparty/libmatio.2.dylib libmatio.2.dylib 

Debugging on MacOS Sierra

At the moment, gdb & apple-gdb have trouble with Sierra, so lldb is favored to debug Scilab.
For bin/scilab -nwni -debug to launch lldb instead of gdb, you need to replace in bin/scilab:

If you are having "NameError: name 'run_one_line' is not defined" errors, you must install the "six" library.
With MacPorts this is done by sudo port install py-six.

install_name_tool -id @executable_path/../lib/thirdparty/libmatio.2.dylib libmatio.2.dylib 

Mac OS X Scilab 6.0.1 - MacOSX 64 bits, (scilab-6.0.1-x86_64.dmg - 224M) (dmg)

Running Scilab 6.0.1 on MacOS Mojave

You have to remove some libraries bundled with Scilab. In order that you just have to copy/paste the following commands in the terminal, make sure that you have copied scilab 6.0.1 to the /Applications folder:

rm /Applications/scilab-6.0.1.app/Contents/MacOS/lib/thirdparty/libBLAS.dylib

rm /Applications/scilab-6.0.1.app/Contents/MacOS/lib/thirdparty/libz.1.dylib

After removing these libraries, Scilab should start. However, you may be prompted to install an old Java version, which is available at the following url: 

https://support.apple.com/kb/dl1572

public: Compiling Scilab under MacOSX (last edited 2018-12-07 19:27:40 by run-publicip4)