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:
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?