External Interfaces/API | ![]() ![]() |
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
setenv LD_LIBRARY_PATH <matlab>/extern/lib/$Arch:$LD_LIBRARY_PATH
In Bourne shell, the commands to set the library path are
LD_LIBRARY_PATH=<matlab>/extern/lib/$Arch:$LD_LIBRARY_PATH export LD_LIBRARY_PATH
where <matlab>
is the MATLAB root directory and $Arch
is your system architecture (alpha
, glnx86
, sgi
, sol2
, hp700
, or ibm_rs
).
Note that the environment variable (LD_LIBRARY_PATH in this example) varies on several platforms. This table lists the different environment variable names you should use on these systems.
Architecture |
Environment Variable |
HP700 |
SHLIB_PATH |
IBM RS/6000 |
LIBPATH |
SGI 64 |
LD_LIBRARY64_PATH |
It is convenient to place these commands in a startup script such as ~/.cshrc
for C shell or ~/.profile
for Bourne shell.
Compiling and Linking
MATLAB provides an options file, engopts.sh
, that lets you use the mex
script to easily compile and link engine applications. For example, to compile and link the engdemo.c
example, you can use
mex -f <matlab>/bin/engopts.sh <pathname>/engdemo.c
where <pathname>
specifies the complete path to the specified file.
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 engopts.sh
file.
Special Consideration for Fortran (f77) on HP-UX 11.x
In the version of the Fortran compiler (f77
) that ships with HP-UX 11.x, the meaning of the -L
flag has changed. The -L
flag now requests a listing. So, to force the linker to see the libraries you want linked in with your code, use
f77 <include dir> -o <result> <source> -Wl,-L<matlab>/extern/lib/hp700 <libraries>
![]() | Compiling and Linking Engine Programs | Compiling and Linking on Windows | ![]() |