One other thing. I am using the instrument control toolbox in matlab to setup GPIB and VISA connections to various instruments. Each of the compiled matlab functions open and close these connections. I was wondering if there was anyway to leave them open between calling each function via mlf<lib>?
Compiling a matlab function into a C shared .dll library
1 view (last 30 days)
Show older comments
I have 5 matlab functions that I have compiled into 5 separate shared C .dll to use with an existing software written in C. Each of these functions are independent of each other and perform a unique procedure using an instrument over VISA. In the application that I want to integrate the matlab shared libraries, the user may select from the UI which procedures to run. It may include all 5 functions, a subset of the 5, or none at all. The user may also choose to rerun any one or all of the functions.
Reading through the Compiler documentation, I found that
<lib>Terminate will bring down enough of the MCR address
space that the same library (or any other library) cannot be initialized.
Issuing a <lib>Initialize call after a <lib>Terminate call causes
unpredictable results. Instead, use the following structure:
...code...
mclInitializeApplication();
lib1Initialize();
lib2Initialize();
lib1Terminate();
lib2Terminate();
mclTerminateApplication();
...code...
So I am wondering what is the best practice here for loading all the libraries. Should I initialize all of them at the beginning of the application, even if I may not use all of them and terminate them all at the conclusion?
Another question is: I have a folder that contains a number of matlab functions that I either wrote myself or downloaded from FEX. The 5 functions that I am compiling separately call some of these functions. Since I am compiling each primary function separately, some of the shared functions may be compiled multiple times. This seems like bad practice. I am wondering if there is an alternative?
Thanks!
Answers (0)
See Also
Categories
Find more on Instrument Control Toolbox Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!