Handle the external reference in the DLL generation TLC files
15 views (last 30 days)
Show older comments
Hello everyone,
I would like to have your opinions about how to solve this issue :
I made some libraries, which involve in several blocks, these ones are basically some sfunctions, which make calls to several external libraries (.lib file).
These libraries are going to be used by other folks to create some simulink models, which will be "transformed' in a DLL, by using Real-Time Workshop (former Simulink Coder) to perform several tests on a external device.
In order to compile the simulink model I have to link the external library used by the block of the library, by adding the name of the library to the compiling instructions of RTW I usually did that with this instruction
set_param(gcs,'CustomLibrary','P3_System_2.lib'
My advisor asks me to simplify the use of the libraries to the other team. He would like when someone adds a block to a model, the external library that is used by the block, will be automatically add to the options of Real-Time Workshop. My solution was to add this instruction
set_param(gcs,'CustomLibrary','P3_System_2.lib'
to the CopyFcn Callback of the block.
But that's not good enough for my purpose, because it's not the optimal solution for the maintenance of the blocks
So I started to study how Real-Time workshop works
I found these references
I understood the DLL generation performed by RTW is essentially controlling by three files that are system target file, template makefile and make command.
So inspiring by this example
I thought to modify the .tlc file (used to specify the system language target) by including in the code the libraries that are requested for the compilation of the model. So I thought to add on the top of the code this instruction
%include "P310_System_2.lib"
I didn't test yet this solution, because I'm not at laboratory and I didn't have the RTW license on my PC
So I would like to have your opinions about this solution, if this one could work, or I'm out-of-way and I should change approach
Every suggestions are welcome
thanks for reading and happy new year of course :)
0 Comments
Accepted Answer
Kaustubha Govind
on 3 Jan 2013
Are these blocks all S-functions? If yes, the right way to do this is to create a rtwmakecfg.m file and place it in the same folder as the S-function MEX-files. Adding your .lib files to makeInfo.linkLibsObjs will ensure that any model that uses your blocks will link against the required libraries.
4 Comments
Kaustubha Govind
on 4 Jan 2013
grapevine: Glad you were able to solve the issue! Regarding the library path not getting resolved - note that the compiling of C code is not actually done by MATLAB itself - MATLAB simply calls into a C-compiler (typically the one selected using "mex -setup") to compile the generated code. The C compiler knows nothing about the MATLAB path. The right way to inform the C compiler about library paths is to either set the complete path using makeInfo.linkLibsObjs, or use makeInfo.library different fields to specify the library name, path, etc.
More Answers (0)
See Also
Categories
Find more on Simulink Coder 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!