Makefile for MEX
14 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Kaustubha Govind
on 7 Apr 2011
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 Comments
Kaustubha Govind
on 8 Apr 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
on 8 Mar 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
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!