Load C++ Library In-Process or Out-of-Process
Load Out-of-Process C++ Library
MATLAB® can run C++ functions in a separate process. Running in a separate process enables you to:
Use some third-party libraries in the code that conflict with MATLAB.
Publishers can use this mode while developing an interface, eliminating the need to restart MATLAB while testing.
Isolate the MATLAB process from crashes in the C++ library code.
To run out-of-process, in your workflow script created by the clibPublishInterfaceWorkflow
function, run the Enable out-of-process
execution mode section. Alternatively, from the command line, call the
clibConfiguration
function with the "ExecutionMode"
argument set to "outofprocess"
.
Unload Out-of-Process C++ Library
If you run the Enable out-of-process execution mode section in the
workflow script created by the clibPublishInterfaceWorkflow
function, then you can unload the C++ library by
running the Unload out-of-process library section.
Alternatively, call unload
on the MATLAB interface. For example, suppose that you built an interface
schoolInterface.dll
to the school
C++ library and
the interface is loaded and set to out-of-process execution. To verify, type:
configObj = clibConfiguration("school")
configObj = CLibraryConfiguration for school with properties: InterfaceLibraryPath: "C:\work" Libraries: "" Loaded: 1 ExecutionMode: outofprocess ProcessID: 12345
To unload the library, type:
configObj.unload
Information About the Host Process
Use the CLibraryConfiguration
object created from calling the
clibConfiguration
function to get information about the host process.
These properties provide information about the settings and status of a MATLAB interface to a C++ library.
InterfaceLibraryPath
contains the path to the interface library.Libraries
contains the names of libraries used to build the interface.Loaded
contains the process status, specified as 1 if the library is loaded, otherwise 0.ExecutionMode
indicates whether to load the C++ interface in the same process as MATLAB, specified asinprocess
oroutofprocess
.ProcessName
contains the name of the host process, which foroutofprocess
isMATLABCLibHost
by default.ProcessID
contains the process identifier.