
Matlab C runtime conflict with instrument drivers
21 views (last 30 days)
Show older comments
Matlab crashes when using calllib. I'm trying to load a C DLL library. This DLL file is an instrument driver from National Instruments (NI).
We have been loading instrument drivers and using them via calllib and never had this issue. This issue only occured with the recent drivers from National instruments but after investigation it seems it is caused by Matlab's C runtime environment.
It seems there is a mismatch in the version of the C runtime DLLs shiped with Matlab and the ones these latest drivers depend on. When the driver is used outside Matlab, it works, but within Matlab it does not (Matlab crashes). This is true also for .NET drivers (NI .NET drivers also wrap the C drivers), For example the following niScope driver (2025 Q4)
if I load the .NET driver of the niScope (NationalInstruments.ModularInstruments.NIScope.Fx45), and execute a function (ex. scope constructor), Matlab crashes. If I attached Microsoft Visual Studio debugger it shows memory access violation. (Attached you can see the full crash log I get from the debugger).
What is the reason of this issue (is it really a mismatch in the C runtime environment)?
1 Comment
Alexander Schreiber
1 minute ago
Dear Hassan,
many thanks for bringing this issue to our attention. Could you please enter a Technical Support case as its resolution might require additional investigation.
Please select one of the below alternatives to enter the case to the system:
1. Within MATLAB, please click on "Request Support" next to Help in the RESOURCES section of the tool strip

2. Through "Contact Support" on our website (https://www.mathworks.com/support/contact_us.html)
Many thanks in advance.
Best regards,
Alex
Answers (0)
See Also
Categories
Find more on C Shared Library Integration 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!