External Interfaces |
Compiling and Linking on UNIX
Under UNIX at runtime, you must tell the system where the API shared libraries reside. These sections provide the necessary UNIX commands depending on your shell and system architecture.
Setting Runtime Library Path
In C shell, the command to set the library path is
where $MATLAB
is the MATLAB root directory and $ARCH
is your system architecture on which MATLAB is supported.
In Bourne shell, the commands to set the library path are
Setting Runtime Library Path on Macintosh
On the Macintosh platform, the library path variable is called DYLD_LIBRARY_PATH
. Use the following commands to set the library path:
In C shell, the command to set the library path is
In Bourne shell, the commands to set the library path are
Platform-Specific Environment Variables
Note that the environment variable (LD_LIBRARY_PATH
in this example) varies on several platforms. The following table lists the different environment variable names you should use on these systems.
Architecture |
Environment Variable |
HP-UX |
SHLIB_PATH |
Mac OS X |
DYLD_LIBRARY_PATH |
It is convenient to place these commands in a startup script such as ~/.cshrc
for C shell or ~/.profile
for Bourne shell.
Using the Options File
MATLAB provides an options file, matopts.sh
, that lets you use the mex
script to easily compile and link MAT-file applications. For example, to compile and link the matcreat.c
example, first copy the file
(where $MATLAB
is the MATLAB root directory) to a directory that is writable, and then use the following command to build it:
If you need to modify the options file for your particular compiler or platform, use the -v
switch to view the current compiler and linker settings and then make the appropriate changes in a local copy of the matopts.sh
file.
Compiling and Linking MAT-File Programs | Compiling and Linking on Windows |
© 1994-2005 The MathWorks, Inc.