MATLAB COMPILER 4 User Manual

Browse online or download User Manual for Unknown MATLAB COMPILER 4. Compiling MATLAB M-Files for Usage Within an C

  • Download
  • Add to my manuals
  • Print
  • Page
    / 21
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 0
Compiling MATLAB M-Files for Usage Within an
C-Application
Peter M. Roth, Martin Winter
{pmroth, winter}@icg.tu-graz.ac.at
December 17, 2004
1 Introduction
1.1 General Notes
The following guideline describes the steps to do to a proper compilation of MATLAB
source code (M-files) for integration into a C/C++ framework, i.e the FSP-Framework
zwork for Computer Vision applications. All examples presented in this work can be
downloaded at [17].
Due to some bugs and unresolved known problems in the MATLAB Compiler (Ver-
sion 3.0) of MATLAB 6.5 Rel.13, it is essential to follow some restrictions and a handful
of workarounds. The presented solutions are partially officially solutions published by
MathWorks Inc. but most of them result from our observations during the attempts to
compile and integrate our MATLAB code into stable applications under Linux.
1.2 Environment for that this guide is valid:
MATLAB 6.5 Rel.13 (Linux, Windows)
Windows XP : Visual Studio 6.0, gcc 2.3.2
Linux: gcc 2.95, gcc 3.2.2, gcc 3.3.1
1.3 Structure of the Document
Section 2 gives a general overview of the usage of the MATLAB Compiler mcc that is
valid for Windows as well as for Linux operating system. Section 3 gives a detailed
guideline for compiling M-files under Windows XP using Visual Studio 6.0, as Section 4
gives a detailed guideline for compiling M-files under a Linux environment. In the e nd
Section 5 gives a short introduction how to include existing compiled M-files into a C
framework.
1
Page view 0
1 2 3 4 5 6 ... 20 21

Summary of Contents

Page 1 - C-Application

Compiling MATLAB M-Files for Usage Within anC-ApplicationPeter M. Roth, Martin Winter{pmroth, winter}@icg.tu-graz.ac.atDecember 17, 20041 Introduction

Page 2 - 2 MATLAB Compiler mcc

4.3 Compiling M-Files to Stand-Alone ApplicationsIt is assumed that there is an M-file that serves as main file, that maybe calls some helperfunctions.

Page 3 - 2.2 mcc Compiler Option Flags

(ii) The CLFAGS used for compiling can be obtained by calling the mmc in the verboseand debug mode. View the output ofmcc -t -W main -h -c -v -G libmm

Page 4

Annotation(i) Libraries under Linux are restricted to the prefix lib in the library name. Using thesecond line the library will be linked to the MATLAB

Page 5 - 2.5 MBUILD

5 Include compiled MATLAB functions to C-code5.1 Preliminary NotesC Code onlyGenerally it is possible to generate C code as well as C++ code from exis

Page 6 - 3 Windows XP

1 #in c lu d e " matlab .h "2 #in c lu d e " l ibsimple .h "34 i n t main ( i n t argc , char * argv [])5 {6 /* define variable s

Page 7

fun cti on [C , D ] = simple (A , B , T e stStr )f p r i n t f ([ TestStr , ’\ n\ n ’]);C = A + B ;D = A * B ;return ;Listing 3: simple.mThis is a Tes

Page 8 - 3.6 Compiling using lcc

5.2.2 Compile the Example Source CodeReferring again to Listing 1 and following the steps in Section 4.4 an instruction forcompiling and linking the e

Page 9 - 4.1 Preliminary Notes

5.4 Simple C++ Template for a MATLAB LibraryIn the following we show a template for a wrapper-class for simply including compiledMATLAB source code in

Page 10 - Annotation

#in c lu d e " wrapper . h"#in c lu d e " libcppdemo . h"// co n structorTemp late _ Comp onen t :: T empl ate_ Comp o nen t (){//

Page 11

Appendix AA.1 Needed M-files for CompilingWe needed to copy all files given in the list below to the local working directory whengenerating C-source cod

Page 12

2 MATLAB Compiler mcc2.1 Preliminary NotesThe MATLAB Compiler mcc can translate M-files into C or C++ source code. Theresulting files can be used in any

Page 13 - 5.2 Example

A.2 Needed MEX-files for compilingAdditionally to the functions that exist as M-file you would need to include those functionsthat are compiled to a MEX

Page 14 - Listing 2: main.c

References[1] Stallman R.M., McGrath R., Smith P., GNU Make, Free Software Foundation, 2002[2] Stallman R.M., Using and Porting the GNU Compiler Colle

Page 15

2.2 mcc Compiler Option FlagsThe following table gives a short overview of the most important compiler option flagsneeded for generation of C/C++ code.

Page 16

2.3 Limitations and RestrictionsThere are some limitations and restrictions using the MATLAB Compiler. Therefore mcc(Version 3.0) cannot compile:• M-fi

Page 17

1. Create a text file containing the text -I dir name for each directory you want onthe default path, and name this file mccpath.2. Place this file in yo

Page 18 - Listing 6: wrapper.cpp

3 Windows XP3.1 Compiling M-files to Stand-Alone Applications• Extract MatLab Compiling Files Win32.zip to the local compiling directory. ThisZIP-file c

Page 19 - Appendix A

• some other c-files, h-files a.s.oNotes:• You can use the .c and .h files for compiling a library with another compiler.• For executing an application i

Page 20

This w ill create an import library for an existing library libname.dll that now can b elinked against an application using gcc. An example bat-file cr

Page 21 - References

4 Linux4.1 Preliminary NotesAll steps described in this section may be done inside the MATLAB environment mucheasier. On the one hand side all the pat

Comments to this Manuals

No comments