How to fix error in Calling MATLAB Functions from C++?
Show older comments
hi i want to execute the first example of "Call MATLAB Functions from C++" that use MATLAB gcd function. when i run the code it doesn't work and show the below error.

how can i fix it?
6 Comments
Walter Roberson
on 28 Feb 2018
Did you try using Dependency Walker or equivalent https://www.raymond.cc/blog/check-what-dll-or-ocx-dependency-files-is-needed-for-a-software/
mohammad yg
on 28 Feb 2018
Edited: mohammad yg
on 28 Feb 2018
Walter Roberson
on 28 Feb 2018
I do not do much Windows work but my memory is that .lib files are static linked and so there is no dll for them.
It seems that there are several issues here:
- It looks like you're trying to step through the code in ntdll.dll. That's a windows dll. Indeed its source code is not available. There is no point in trying to attach a debugger to ntdll. It's not going to help you.
- You're getting an exception because ntdll is trying to load a dll but the dll cannot be found. Unfortunately, the error message you show does not tell us what dll cannot be found. I presume it's one of matlab dll.
Have you followed the instructions on this page and have you tested your build environment and checked that it work?
Guillaume
on 28 Feb 2018
@Walter, yes .lib are statically linked. However, I've just tested an the exe still need the dll version of libMatlabEngine and libMatlabDataArray, presumably because the static libraries loads them.
Walter Roberson
on 28 Feb 2018
When I read about what NTDLL is for, it really looked to me as if it should not be invoking any DLL, as NTDLL is responsible for some services when the NT kernel is not running, such as to be able to create defragmenters that run before the operating system is fully loaded.
Accepted Answer
More Answers (0)
Categories
Find more on Programming 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!