[ Pobierz całość w formacie PDF ]

application must be able to locate the C/C++ libraries along the library path
environment variable (SHLIB_PATH, LIBPATH, or LD_LIBRARY_PATH) in order to
be found and loaded. Consequently, to share a Compiler-generated,
4-12
Building Stand-Alone Applications on UNIX
stand-alone application with another user, you must provide all of the
required shared libraries. For more information about the required shared
libraries for UNIX, see  Distributing Stand-Alone UNIX Applications on page
4-14.
Running Your Application
To launch your application, enter its name on the command line. For example,
ex1
ans =
1 3 5
2 4 6
ans =
1.0000 + 7.0000i 4.0000 +10.0000i
2.0000 + 8.0000i 5.0000 +11.0000i
3.0000 + 9.0000i 6.0000 +12.0000i
Verifying the MATLAB Compiler
There is MATLAB code for an example, hello.m, included in the /
extern/examples/compiler directory . To verify that the MATLAB Compiler
can generate stand-alone applications on your system
, type the following at the
MATLAB prompt.
mcc -m hello.m
This command should complete without errors. To run the stand-alone
application, hello, invoke it as you would any other UNIX application,
typically by typing its name at the UNIX prompt. The application should run
and display the message
Hello, World
When you execute the mcc command to link files and libraries, mcc actually
calls the mbuild script to perform the functions.
4-13
4 Stand-Alone Applications
Distributing Stand-Alone UNIX Applications
To distribute a stand-alone application, you must create a package containing
these files:
" Your application executable.
" The contents, if any, of a directory named bin, created by mbuild in the same
directory as your application executableNote: mbuild does not create a bin
.
directory for every stand-alone application.
" Any custom MEX-files your application uses.
" All the MATLAB Math run-time libraries.
For specific information about packaging these files, see  Distributing
Stand-Alone Applications in the MATLAB C Math Library User s Guide.
Note There is no support for the MATLAB C/C++ Graphics Library on the
IBM_RS platform.
Remember to locate the shared libraries along the LD_LIBRARY_PATH
(SHLIB_PATH on HP) environment variable so that they can be found and
loaded.
Installing C++ and Fortran Support
MATLAB users require access to both the C++ and Fortran run-time shared
libraries. These are usually provided as part of the operating system
installation. For Digital UNIX, however, the C++ shared libraries are part of
the base installation package, but the Fortran shared libraries are on a
separate disk called the  Associated Products CD. MATLAB users running
under Digital UNIX should install both the C++ and Fortran run-time shared
libraries.
Note If you distribute an application created with the math libraries on
Digital UNIX, your users must have both the C++ and Fortran run-time
shared libraries installed on their systems.
4-14
Building Shared Libraries
Building Shared Libraries
You can use mbuild to build C shared libraries on both UNIX and the PC . All
of the mbuild options that pertain to creating stand-alone applications also
pertain to creating C shared libraries. To create a C shared library, specify one
or more files with the .exports extension. The .exports files are text files that
contain the names of the functions to export from the shared library, one per
line. You can include comments in your code by beginning a line (first column)
with # or a *. mbuild treats these lines as comments and ignores them. mbuild
merges multiple .exports files into one master exports list.
For example, given file1.exports as
times2
times3
and file1.c as
int times2(int x)
{
return 2 * x;
}
int times3(int x)
{
return 3 * x;
}
The command
mbuild file1.c file1.exports
creates a shared library named file1.ext, where ext is the
platform-dependent shared library extension.
For example, on the PC, it would
be called file1.dll. The shared library exports the symbols times2 and
times3.
4-27
Coding with M-Files Only
Coding with M-Files Only
One way to create a stand-alone application is to write all the source code in
one or more M-files or MEX-files. Coding an application in M-files allows you
to take advantage of MATLAB s interpretive development environment.Then,
after getting the M-file version of your program working properly, compile the
code and build it into a stand-alone application.
Note It is good practice to avoid manually modifying the C or C++ code that
the MATLAB Compiler generates. If the generated C or C++ code is not to
your liking, modify the M-file (and/or the compiler options) and then
recompile. If you do edit the generated C or C++ code, remember that your
changes will be erased the next time you recompile the M-file. For more
information, see  Compiling MATLAB Provided M-Files Separately on page [ Pobierz całość w formacie PDF ]
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • szamanka888.keep.pl