| MATLAB® | ![]() |
| On this page… |
|---|
Compiling and Linking on UNIX® Operating Systems Compiling and Linking on Windows® Operating Systems |
At run-time, you must tell the UNIX®[1] operating system where the API shared libraries reside. These sections provide the necessary UNIX commands, depending on your shell and system architecture.
Set the library path as follows for the C and Bourne shells. Replace the terms envvar and pathspec with the appropriate values from the table below.
In the C shell, set the library path using the command:
setenv envvar pathspec
In the Bourne shell, use:
envvar = pathspec:envvar export envvar
| Operating System | envvar | pathspec |
|---|---|---|
Linux®[a] | LD_LIBRARY_PATH | matlabroot/bin/glnx86: matlabroot/sys/os/glnx86 |
64-bit Linux | LD_LIBRARY_PATH | matlabroot/bin/glnxa64: matlabroot/sys/os/glnxa64 |
64-bit Sun™Solaris™ SPARC® | LD_LIBRARY_PATH | matlabroot/bin/sol64: matlabroot/sys/os/sol64 |
Apple® Macintosh® (Intel®) | DYLD_LIBRARY_PATH | matlabroot/bin/maci: matlabroot/sys/os/maci |
[a] Linux is a registered trademark of Linus Torvalds. | ||
For example, for the C shell on a Solaris system use:
setenv LD_LIBRARY_PATH matlabroot/bin/sol64:matlabroot/sys/os/sol64
and for the Bourne shell:
LD_LIBRARY_PATH=matlabroot/bin/sol64:matlabroot/sys/os/sol64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH
You can place these commands in a startup script such as ~/.cshrc for C shell or ~/.profile for Bourne shell.
The MATLAB® options file, matopts.sh, 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 using the command:
matlabroot/extern/examples/eng_mat/matcreat.c
to a writable directory, then use the following command to build it:
mex -f matlabroot/bin/matopts.sh matcreat.c
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.
To compile and link Fortran or C MAT-file programs, use the mex script with a MAT options file. The MAT options files reside in matlabroot\bin\win32\mexopts or matlabroot\bin\win64\mexopts and are named *engmatopts.bat, where * represents the compiler type and version.
For example, to compile and link the stand alone MAT application matcreat.c using the Microsoft® Visual C++® Version 7.1 compiler on a Microsoft® Windows® operating system, first copy the file:
matlabroot\extern\examples\eng_mat\matcreat.c
to a writable directory, and then use the following command to build it:
mex -f matlabroot\bin\win32\mexopts\msvc71engmatopts.bat matcreat.c
If you need to modify the options file for your particular compiler, use the -v switch to view the current compiler and linker settings and then make the appropriate changes in a local copy of the options file.
MATLAB requires the following data and library files for building any MAT-file application. You must also distribute these files along with any MAT-file application that you deploy to another system.
When building a MAT-file application on your system or deploying a MAT-file application to some other system, make sure that the appropriate Unicode® data file is installed in the matlabroot/bin/$ARCH directory. MATLAB uses this file to support Unicode encoding.
For systems that order bytes in a big-endian manner, use icudt32b.dat.
For systems that order bytes in a little-endian manner, use icudt32l.dat.
When building a MAT-file application on your system or deploying a MAT-file application to some other system, make sure to install the appropriate libraries in the matlabroot/bin/$ARCH directory:
Library File Names by Operating System
| Windows | UNIX | Macintosh (Intel) |
|---|---|---|
| libmat.dll | libmat.so | libmat.dylib |
| libmx.dll | libmx.so | libmx.dylib |
In addition to these libraries, you must also have all third-party library files that libmat depends on. MATLAB uses these additional libraries to support Unicode character encoding and data compression in MAT-files. These library files must reside in the same directory as libmx.
You can determine what most of these libraries are using the platform-specific methods described below.
Type the following command:
ldd -d libmat.so
Type the following command:
otool -L libmat.dylib
Download the Dependency Walker utility from the following Web site:
http://www.dependencywalker.com/
and then drag and drop the file matlabroot/bin/win32/libmat.dll or matlabroot/bin/win64/libmat.dll into Depends window.
If you need to manipulate Unicode text directly in your application, the latest version of International Components for Unicode (ICU) is freely available online from the IBM® Corporation Web site at:
http://icu.sourceforge.net/download
[1] UNIX is a registered trademark of The Open Group in the United States and other countries.
[a] Linux is a registered trademark of Linus Torvalds.
![]() | Examples of MAT-Files | MATLAB® Interface to Generic DLLs | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |