Personal tools
You are here: Home Developer Infrastructure Teams Build and Release Instructions to build Matlab JNI libraries in Kepler for Matlab actor

Instructions to build Matlab JNI libraries in Kepler for Matlab actor

To run Matlab actor in Kepler, the Matlab JNI library sometimes needs to be rebuilt. This page explains how to create the Matlab libraries for users own environments.

Matlab JNI libraries are needed to run Matlab actor in Kepler. The matlab libraries in Kepler release may not work in Kepler under a certain combination of Java, Operating System and Matlab. If not, please try the following steps to build the library for your own environment.

For 64 bit windows, the first solution you can try is renaming $Kepler\common\lib\ptolemy\matlab\ptmatlab64.dll to ptmatlab.dll, and restart Kepler to see whether it works. For 64 bit Linux, please try renaming $Kepler\common\lib\libptmatlab64.so to libptmatlab.so, and restart Kepler to see whether it works.

Below are instructions for building the Matlab shared library.  To use the Matlab interface, see Setting up Mac OS X to use the Matlab Interface.

 Installing 32bit Mingw for 32bit Windows

The default gcc compiler shipped with Cygwin will produce .dll files that do not work properly.  The solution is to install Mingw.

  1. Install Cygwin either from http://www.cygwin.com or from the Ptolemy distribution.
  2. Start Cygwin bash, create c:\mingw
  3. mkdir c:/mingw
    cd c:/mingw
  4. Copy the mingwdl.sh script from http://www.mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite and paste it into an editor and create c:/mingw/mingwdl.sh
  5. Execute mingwdl.sh, which will download the binaries into c:/mingwdl.
    bash mingwdl.sh
  6. Unzip the .tar.gz files
    gunzip *.gz
  7. Uncompress the .tar.lzma files:
    lzma -d *.lzma
  8. untar the .tar files.  Create a script called mingwuntar.sh:
    #!/bin/sh
    tars=`ls *.tar`
    for tar in $tars
    do
        echo $tar
        tar -xf $tar
    done
  9. Run mingwuntar.sh
    bash mingwuntar.sh
  10. Add c:\mingw\bin to your Windows path Based on the Mingw instructions:
    1. Right-click on "My Computer" and select "Properties".
    2. Click Advanced | Environment Variables.
    3. In the box entitled "System Variables" scroll down to the line that says "PATH" and double-click the entry.
    4. You will be presented with a dialog box with two text boxes, the bottom text box allows you to edit the PATH variable. It is very important that you do not delete the existing values in the PATH string, this will cause all sorts of problems for you!
    5. Scroll to the end of the string and at the end add ";C:\mingw\bin". Don't forget the semicolon; this separates the entries in the PATH.
    6. press OK | OK | OK and you are done.

 

Instructions to build Matlab libraries in Kepler EXCEPT for 64 bit Windows

  1. Add the Matlab shared libraries to your the library path. $MATLAB should be the location of your Matlab installation. For example, if /usr/bin/matlab is a link:
    bash-3.2$ which matlab
    /usr/bin/matlab
    bash-3.2$ ls -l /usr/bin/matlab
    lrwxr-xr-x  1 root  wheel  42 Jan 15 20:57 /usr/bin/matlab -> /Applications/MATLAB_R2009b.app/bin/matlab
    bash-3.2$
    Then $MATLAB would be /Applications/MATLAB_R2009b.app
    32 Bit Mac (10.5?)
    export DYLD_LIBRARY_PATH=$MATLAB/bin/maci
    64 Bit Mac (10.6?)
    export DYLD_LIBRARY_PATH=$MATLAB/bin/maci64
    32 Bit Linux
    export LD_LIBRARY_PATH=$MATLAB/bin/gnlx86
    64 Bit Linux
    export LD_LIBRARY_PATH=$MATLAB/bin/glnxa64
    Windows
    Be sure that the matlab binary is in your path
  2. Add the matlab binary to your PATH
  3. Set PTII
    export PTII=$Kepler/ptolemy/src
  4. Run configure
    cd $PTII
    ./configure
  5. Run make in $PTII/ptolemy/matlab
    cd $PTII/ptolemy/matlab
    make clean
    make
  6. Copy the generated library into the Kepler common library directory:
    32 Bit Mac (10.5?)
    copy libptmatlab.jnilib into $Kepler/common/lib/ptolemy/matlab/
    64 Bit Mac (10.6?)
    copy libptmatlab.jnilib into $Kepler/common/lib64/ptolemy/matlab/
    32 Bit Linux
    copy libptmatlab.so into $Kepler/common/lib/
    64 Bit Linux
    copy libptmatlab.so into $Kepler/common/lib64/
    32 Bit Windows
    copy ptmatlab.dll into $Kepler/common/lib/ptolemy/matlab/
  7. Be sure that the matlab binary is in your path
  8. Restart Kepler

A demo matlab workflow is at $DEMODIR/Matlab/MatlabExpression.xml

Instructions to build Matlab libraries in Kepler for 64 bit Windows

  1. Download and install 64 bit Mingw: See http://sourceforge.net/projects/mingw-w64/
  2. Add installed mingw-w64 into your Windows path:
    1. Right-click on "My Computer" and select "Properties".
    2. Click Advanced | Environment Variables.
    3. In the box entitled "System Variables" scroll down to the line that says "PATH" and double-click the entry.
    4. You will be presented with a dialog box with two text boxes, the bottom text box allows you to edit the PATH variable. It is very important that you do not delete the existing values in the PATH string, this will cause all sorts of problems for you!
    5. Scroll to the start of the string and at the beginning add the bin path of your installed mingw-w64, such as "D:\tools\MinGW-64bit\mingw64\bin;". The reason to put it at the beginning is because we need make sure the gcc command in mingw, instead of the gcc in cgywin, will be used. Don't forget the semicolon; this separates the entries in the PATH.
    6. press OK | OK | OK and you are done.
  3. Go through step 1-5 in the section 'Instructions to build Matlab libraries in Kepler except 64 bit Windows'. The last step will have error since we haven't build make instructions for 64 bit windows
  4. Start a cmd console (not in Cygwin!). Run gcc compile command.
    cd %PTII%\ptolemy\matlab
    gcc -DPT_NO_ENGGETARRAY -DPT_NO_ENGPUTARRAY -DPT_NO_MXGETNAME "-I%MATLAB%/extern/include" "-I%JAVA_HOME%/include"      "-I%JAVA_HOME%/include/win32" -shared ptmatlab.cc -fno-exceptions -o ptmatlab.dll    "-L%MATLAB%/bin/win64" -Wl,--add-stdcall-alias -leng -lmx -lmex
  5. Copy generated ptmatlab.dll into $Kepler/common/lib64/ptolemy/matlab directory.
  6. Restart Kepler
Document Actions