- It is not to make MEX-files static libraries, because MATLAB cannot dynamically load static libraries - your MEX-file would then need to be compiled in with the MATLAB executable itself.
- If you are linking against purely static libraries (it is also possible that your .lib file is only an import library for a DLL that is required at runtime), then the MEX-file already includes the library code in itself. I think the problem you are facing is because Real-Time Workshop (now Simulink Coder) generates standalone code for your model, which is separate from an already compiled MEX-file. At the time that this new code needs to be compiled, your libraries are needed. I can't think of a way you can get around this.
- You can add the "-l" option to the Simulink Coder compiler command by adding your libraries (along with their full path) to the Code Generation>Custom Code>Libraries section of the Confiuration Parameters window.
build a static library instead of a dynamic one with MEX compiler
19 次查看(过去 30 天)
显示 更早的评论
Hello
I m looking for an option of the mex compiler in order to produce a static mex file with all the code, that it needs, already inside it. which can substitute all the external references inside my c code with the real code from the external library.
i tried to do that because I created a mex file to put inside a 2ndlevel sfunction block mex file.c -l APP_Numerical and until now everything is fine the program works on Simulink (the option -l is there, because I made some references to an external library)
Then in order to use it in a real time simulator, I need to translate this model with Real-Time Workshop (now Simulink Coder), but when I attempt to do that I get an error from the linker, which cannot find an external reference; i tried to add this library to the matlab path, but it doesn't work, then I fix it adding the static path of this library (.lib) in the option of Real-Time Workshop.
Is that any way to avoid that? I don't work with the same computer all the time, sometimes I need to switch it with other guys. So everytimes that I need to rebuild the library I need to looking for this library inside the new computer and put its path in the option of Real-Time Workshop.
So I was wondering if there is a way to ask to the mex compiler to substitute all the external references with the real code from the external library. In this way instead to produce a dynamic library it will produce a static library with all the code that it needs already inside it.
0 个评论
回答(1 个)
Kaustubha Govind
2012-2-22
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!