Main Content

Restore Library Definition

While publishing a MATLAB® interface to a C++ library, you might iterate over the steps, close and reopen the clibPublishInterfaceWorkflow workflow script, or restart MATLAB. If you restart MATLAB before completing the steps to publish an interface, you might see this error:

Unable to resolve the name 'libraryDefinitionFromTask.InterfaceName'.

To preserve your workflow script, use the 1a: Restore library definition step in the script to create a libraryDefinitionFromTask variable. To create the variable, set these variables in the code section:

  • Set the outputFolderPath variable to the value of the Output folder parameter in the Live Editor task.

  • Set the libraryNameForInterface variable to the value of the Name of interface library parameter in the Live Editor task.

if evalin('base','exist(''libraryDefinitionFromTask'',''var'') == 0')
    outputFolderPath = ""; % Set outputFolderPath to the live task Output folder selection
    libraryNameForInterface = ""; % Set libraryNameForInterface to the live task Name of interface library
    if outputFolderPath ~= "" && libraryNameForInterface ~= ""
        libraryDefinitionFromTask = feval("define"+libraryNameForInterface);
    clear outputFolderPath libraryNameForInterface

Save your workflow script. If you exit and restart MATLAB, then you can continue using the workflow script to publish a MATLAB interface to your C++ library.


The best practice is to create the libraryDefinitionFromTask variable after clicking Generate definition file in the Live Editor task step 1.

While developing an interface, consider using the 4b: Enable out-of-process execution mode step in the workflow script. For more information, see Load C++ Library In-Process or Out-of-Process.