Why does my MATLAB-compiled library (DLL) fail to initialize when deploying a driver application built with LabWindows/CVI?

9 views (last 30 days)
I have compiled a C shared library (DLL) using the MATLAB Compiler. I am using the DLL in a project I am developing with the National Instruments LabWindows/CVI IDE.
In debug mode, I am able to successfully initialize the MATLAB Compiler Runtime along with my DLL, and use the DLL functions from the application. I then create a Distribution via a .cds file configuration and build my application in Release mode. This creates an installation package for my application.
I then run the installer and install my application on a deployment machine. My MATLAB-compiled DLL is also installed by the package, as it was detected as a file dependency. When I run the deployed application, however, the MATLAB-compiled DLL fails to initialize; that is, the <libname>Initialize() routine returns as failure.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 28 Nov 2016
When building an installer package with a Distribution in LabWindows/CVI, two default behaviors occur in the program that will prevent the MATLAB-compiled DLL from initializing properly when deployed alongside your application. These behaviors are listed below, along with ways to work around them:
(1) If you are using a pre-R2008a version of the MATLAB Compiler, or if you are compiling your DLL using the R2008a version with the -C flag to override the default CTF embedding behavior, the LabWindows/CVI Build tool will not pick up the dependency between the DLL and its corresponding CTF-file.
You will need to manually specify in the Distribution configuration that the CTF-file be installed in the same directory as the DLL.
(2) The LabWindows/CVI Build tool, by default, makes a copy of MATLAB's mclmcrrt7x.dll in your application's installation directory in the deployment machine. If this file is picked up from this directory instead of mcr_root\version\runtime\win32, it cannot properly load other necessary MATLAB Compiler Runtime libraries.
You will need to configure your Distribution such that it does not install this library to your application's installation directory.

More Answers (0)

Categories

Find more on MATLAB Compiler 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!