Personal tools
You are here: Home Developer Infrastructure Teams Build and Release Setting up Mac OS X to use the Matlab Interface

Setting up Mac OS X to use the Matlab Interface

To use the Matlab Interface under Mac OS X requires some set up.

Under Mac OS X, the Matlab interface requires that the DYLD_LIBRARY_PATH environment variable be set to include the Matlab shared libraries.

For example, if you are running Mac OS X 10.7, your Matlab installation is at /Applications/MATLAB_R2011a.app, the DYLD_LIBRARY_PATH variable needs to be set to /Applications/MATLAB_R2011a.app/bin/maci64

In addition, your path needs to include the directory that contains the "matlab" command.

 

Unfortunately, there are complications.

32-bit or 64-bit

The exact path depends on whether you are running a 32-bit Java Virtual Machine or a 64-bit virtual machine.  As of August, 2011, it seems that Mac OS X 10.5 may be running a 32-bit Java Virtual Machine and Mac OS X 10.6 and later is running a 64-bit virtual machine.  

 

To test, run java -version. 

bash-3.2$ java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

The above indicates that a 64-bit Java Virtual Machine is in use.

If the Matlab installation is at $MATLAB, then for 64-bit virtual machines, set the value of DYLD_LIBRARY_PATH to $MATLAB/bin/maci64.

If the Matlab installation is at $MATLAB, then for 64-bit virtual machines, set the value of DYLD_LIBRARY_PATH to $MATLAB/bin/maci.

Setting Environment Variables for Applications

Unfortunately, Mac OS X has a very arcane way of setting properties for applications that are started by clicking on an icon.

The preferred way is to use the "Property List Editor" application, see http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/EnvironmentVars.html

Unfortunately, "Property List Editor" is part of XCode and XCode 4.x is not free and is a very large download.  If XCode is installed, then "Property List Editor" might be found in Macintosh HD/Developer/Applications/Utilities/Property List Editor.

An alternative to using "Property List Editor" is to create ~/.MacOSX/.environment.plist with a text editor such as TextEdit

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>DYLD_LIBRARY_PATH</key>
        <string>/Applications/MATLAB_R2011a.app/bin/maci64/</string>
</dict>
</plist>

No matter how ~/.MacOSX/.environment.plist is created, log out and log back in again to get the updated values.

 

Setting the Path

The Matlab actor looks for the "matlab" executable.  If the "matlab" executable cannot be found, the following error message appears:

ptolemy.kernel.util.IllegalActionException: matlabEngine.open(null) : can't find Matlab engine.Try starting Matlab by hand as an application to verify that Matlab is set up properly and the license is correct. Under Windows, try running "matlab /regserver", the Matlab C API communicates with Matlab via COM, and apparently the COM interface is not automatically registered when Matlab is installed. Under Linux and other types of UNIX, csh must be installed in /bin/csh.
    at ptolemy.matlab.Engine.open(Engine.java:280)
    at ptolemy.matlab.Engine.open(Engine.java:232)
    at ptolemy.matlab.Expression.preinitialize(Expression.java:303)
    at ptolemy.actor.Director.preinitialize(Director.java:1010)
    at ptolemy.actor.Director.preinitialize(Director.java:991)
    at ptolemy.domains.sdf.kernel.SDFDirector.preinitialize(SDFDirector.java:647)
    at ptolemy.actor.CompositeActor.preinitialize(CompositeActor.java:1735)
    at ptolemy.actor.Manager.preinitializeAndResolveTypes(Manager.java:983)
    at ptolemy.actor.Manager.initialize(Manager.java:643)
    at ptolemy.actor.Manager.execute(Manager.java:340)
    at ptolemy.actor.Manager.run(Manager.java:1164)
    at ptolemy.actor.Manager$3.run(Manager.java:1217)

Unfortunately, we can't use environment.plist to set the path for applications started by clicking on icon because we would end up overwriting the path set for other applications.

The trick is to create a symbolic link in /usr/bin to the matlab script.  To create this file requires becoming root usng the "sudo" command:

sudo ln -s /Applications/MATLAB_R2011a.app/bin/matlab /usr/bin/matlab
Document Actions