EPFLSTILOBMarcel LeuteneggerAbout

MATLAB toolbox

MEX-Builder and file versioning

MATLAB toolbox

Data types

Double class
Extended class
Single class


Flex99-12C correlator
Flex02-0xD correlator
Vector functions


C-MEX wrapper
FPU instructions


Error function
Hankel transform


The MATLAB compiler toolbox builds native libraries (MEX-functions) and executables (applications) for different platforms. The compiler scripts mex and mcc offer a user-friendly interface for compiling and linking M, C, C++, Fortran and assembler files. This package adds automatic file versioning and copyright information included in the MEX-libraries for Microsoft Windows.



Unpack the functions in a folder within the MATLAB path.

Insert the path to nasmw.exe on line 78 of mexmake.m.

78:      eval(['!"path\nasmw.exe" -f win32 -o "' file '" "' f.Files{n} '"']);

Using MEX-Builder

MEX-Builder manages the file, version and copyright information in a MAT-file version.mat. Prior to the first build, you have to initialize this file. Define the file information f and the product information p at the command prompt and save them to the version.mat.

* A common field requested at least once. If defined twice, the file information takes precedence over the product information.

° A common but optional field. If defined twice, the file information takes precedence over the product information.

File information structure
Field Description
f.CompanyName* Enterprise or author (string).
f.FileDescription Description (string).
f.FileName Name of the MEX-function (string).
f.Files List of files forming the MEX-function (cell of strings).
f.FileVersion File version [major,minor,patch,build] (integers).
f.LegalCopyright* Copyright note (string).
f.LegalTrademarks* Trademarks (string).
f.PrivateBuild° Flags the MEX-function for internal use only (string).
f.SpecialBuild° Flags particular options for building the MEX-function (string).

The file information is an array of named structures. Each entry describes a MEX-function.

Product information structure
Field Description
p.CompanyName* Enterprise or author (string).
p.LegalCopyright* Copyright note (string).
p.LegalTrademarks* Trademarks (string).
p.PrivateBuild° Flags the MEX-function for internal use only (string).
p.ProductName Product or package containing the MEX-function (string).
p.ProductVersion Product version [major,minor,patch,build] (integers).
p.SpecialBuild° Flags particular options for building the MEX-function (string).

The product information is a simple named structure.

Build the MEX-function(s)

Change into the folder of the version.mat and execute


MEX-Builder always optimizes the function(s) (-O option). It recognizes the -inline option for adding the SpecialBuild information "Matrix accessor functions inlined."

You can pass a list of functions to build. By default, the entire product including all functions is built.

MEX-Builder adds a comment to the file information: "MEX-function for MATLAB 6.0 or newer." respectively "MEX-function for MATLAB 6.0." with inlining.


MEX-Builder is freeware. The author reserves the right to modify any of the contained files.

You are allowed to distribute it as long as you deliver the entire, original package for free.

Path File Description
/ mexmake.m Build MEX-functions
mexversion.m Set MEX version
Readme.txt This manual


Any warranty is strictly refused. Don't rely on any financial or technical support in case of malfunction or damage.

Comments are welcome. I will try to track reported problems and fix bugs.


May 26, 2005

Initial release.


Downloading these files, you accept the copyright terms.


MATLAB is a registered trademark of The MathWorks, Inc. Other product or brand names are trademarks or registered trademarks of their respective holders.

© 2011 École Polytechnique Fédérale de Lausanne