Compiling with Mex - Can I reference Environment Variables?
Mostrar comentarios más antiguos
I'm attempting to compile a Simulink S-Function with Mex, which #includes some header files that are from another directory on our system. This directory is defined in an environment variable.
Is it possible to reference the environment variable in the mex -I or -L options?
e.g. mex -I$(REF_DIR)/include my_sfunction.c
On Windows, this is tricky as you refer to environment variables using %REF_DIR%, which won't work in Matlab, as % signifies a comment
Do I just have to bite the bullet and put in the full path? Or edit mexopts.bat?
Respuestas (2)
Kaustubha Govind
el 7 de Sept. de 2011
Try:
mex -v COMPFLAGS="$COMPFLAGS -I%REF_DIR%/include" my_sfunction.c
I think this command, or a minor variation on it should work.
1 comentario
Danny S
el 7 de Sept. de 2011
James Tursa
el 8 de Sept. de 2011
Have you tried the function version of the mex command? E.g.,
mex('-v','COMPFLAGS="$COMPFLAGS -I%REF_DIR%/include"','my_sfunction.c')
This will force the arguments with embedded spaces to be interpreted by the mex command as single arguments instead of multiple arguments. You might need to make the 'COMPFLAGS=' a separate argument from the "etc" part ... not sure about this.
3 comentarios
Danny S
el 8 de Sept. de 2011
James Tursa
el 8 de Sept. de 2011
Can you double up the double quotes inside the double quotes? e.g.,
"$COMPFLAGS -I""%REF_DIR%""/include"
Timothé Boutelier
el 23 de Mzo. de 2017
use simple quote instead of double quote: mex -v COMPFLAGS='$COMPFLAGS -I%REF_DIR%/include' my_sfunction.c
Categorías
Más información sobre Simulink Coder en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!