Makefile for MEX

We have all of our guidance, navigation, and control software running as a C function within LabVIEW (to interface with our sensors). My manager asked me to write a MEX wrapper to feed in old sensor data into our code so we can check for bugs outside of our embedded system without having to re-deploy and run our test vehicle every time we update our software.
We are currently compiling several source files using a makefile into a .out library, but everything is accessed through one executive function. Can any one recommend an easy way to do this? Is it easiest to do this direct from Visual Studio (2010) or from within Matlab? And will I need to write a makefile for this, or do the mex commands do this automatically somehow?
If I do need a makefile, could anyone post an example? I've been having difficulty finding any references on this.

Respuestas (1)

Kaustubha Govind
Kaustubha Govind el 7 de Abr. de 2011

1 voto

You will need to modify your "main executive function" into a MEX-function. Once you have done this, you can simply use the "mex" command to compile all your source files and link them against the MEX-function. For example:
mex mymainmexfunction.c srcfile1.c srcfile2.c srcfile3.c
You add also link against C/C++ object files or libraries just like you would at any other compiler's command line.

3 comentarios

Ted Steiner
Ted Steiner el 7 de Abr. de 2011
Thank you for your response. I already understand more or less the basics of how a MEX function works, but I have 50+ source files to compile, and I will need to recompile frequently, so I'm wondering if I could simplify the process using a makefile. Any tips on writing the makefile or using a makefile within Matlab would be greatly appreciated.
Kaustubha Govind
Kaustubha Govind el 8 de Abr. de 2011
You should be able to use general makefile rules such as:
SRC=$(wildcard '*.c')
mymexfile.mexw64: $(SRC)
mex $^ $@
Run this makefile from MATLAB using something like:
>> !nmake -f Makefile.mk
GOPIKA  AJITH
GOPIKA AJITH el 8 de Mzo. de 2021
Hi mam
I would like to know how to call petsc from within matlab.
Currently I am using "unix(sprintf('make TARGET'));"
But I am getting error.
Thanks

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB Compiler en Centro de ayuda y File Exchange.

Preguntada:

el 7 de Abr. de 2011

Comentada:

el 8 de Mzo. de 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by