Azzera filtri
Azzera filtri

Question about building MEX file

1 visualizzazione (ultimi 30 giorni)
Jeff
Jeff il 8 Set 2012
Hello,
I'm learning others' work on building MEX file and find a command like the following:
mex [certain source files] rfsub.o -o mexClassRF_train -lm -DMATLAB -O -v
I have several questions about this command and couldn't find answers from google...
1) rfsub.o is certain pre-compiled object file that has been provided, I can't figure out the usage of this 'rfsub.o' in the command line. (My guess is rfsub.o is actually the object file compiled from the source files, namely the output of this mex command, the author provided the pre-compiled file just for our convenience. If my guess is right then the 'rfsub.o' in the command line is to define the name of output?)
2) What is '-lm' for? I check the document, there's an option '-lname' which is for linking with object library, so I guess -lm means linking with a library named 'm'? However I couldn't find any file provided with name 'm', seems my guess is wrong...
3) What is -DMATLAB for? Again the document says '-D' is equivalent to '#define name directive' in C/C++, I still can't get it, in C/C++ when you define something you have #define name value, here you only have #define name, what's that mean then?
Thank you in advance!

Risposta accettata

Walter Roberson
Walter Roberson il 9 Set 2012
In that context, rfsub.o means to link in the already-compiled source for rfsub
The output in that command is given by the -o ("output") flag, as mexClassRF_train
-lm does indeed link in a library named "m". That is the common name used for the C math library, and would probably be in the directories provided with the compilers.
-DMATLAB does define the symbol MATLAB. In C and C++ it is not necessary to provide a value. As the Microsoft documentation says,
A #define without a token-string removes occurrences of identifier from the source file. The identifier remains defined and can be tested using the #if defined and #ifdef directives.
  1 Commento
Kaustubha Govind
Kaustubha Govind il 10 Set 2012
You might want to search for "libm" instead of just "m".

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB Compiler in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by