How do I configure my IDE to compile MATLAB Engine applications?

4 visualizaciones (últimos 30 días)
I would like to use my IDE (Visual Studio .Net 2003, etc.) to compile a MATLAB Engine application.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 20 de Jun. de 2011
This change has been incorporated into the documentation in Release 2011a (R2011a). For previous releases, read below for any additional information:
To compile MATLAB Engine applications in a specific IDE, you need to modify your pre-processor include path, and tell the linker what libraries to link against and where to find those libraries.
To determine this, setup your compiler first using "mex -setup" and then compile one of the MATLAB Engine examples with the "-v" flag in order to see how MEX calls your compiler and linker. When it calls your compiler and linker, it will show all of the things mentioned above. You then need to put them into your IDE project settings.
For example, from inside MATLAB, the command:
mex -v -f d:\maTLAB7\bin\win32\mexopts\msvc71engmatopts.bat engdemo.c
produces many lines of output, but most importantly these two:
"cl -c -Zp8 -G5 -W3 -nologo /Foengdemo.obj
-ID:\MATLAB7\extern\include
-ID:\MATLAB7\simulink\include
-O2 -DNDEBUG engdemo.c"
"link "/out:engdemo.exe" kernel32.lib user32.lib gdi32.lib
/LIBPATH:"D:\MATLAB7\extern\lib\win32\microsoft\msvc71"
libmx.lib libmat.lib libeng.lib /nologo @9554_tmp.rsp "
From these, and for the installation of MATLAB on the computer where this example was performed (you may have installed MATLAB in a different directory or on a different drive), we can see that we need to add include paths of:
D:\MATLAB7\extern\include
D:\MATLAB7\simulink\include
Also, we need to specify the following libraries for linking against:
libmx.lib
libmat.lib (only if your code uses the MAT-file API)
libeng.lib
And, we need to add to our linker library path:
D:\MATLAB7\extern\lib\win32\microsoft\msvc71
Where these settings are depends on your IDE, and you may need to contact the maker of your IDE if you can not locate this in the documentation for your IDE or in the solutions database on their web site.

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by