Test my build environment does not work

1 次查看(过去 30 天)
I am facing a strange problem with building a client program with mex. In short: compilation runs fine, but at execution I get an exception "The specified module could not be found".
I want to call some Matlab functions from a C++ program, and as a start, I follow the test Test Your Build Environment.
I am running Matlab 2019b on Win7.
I configure mex for c++ :
mex -setup c++
Strangely enough, it does not give me the choice of the compiler and takes 'Microsoft Visual C++ 2017' (Professional, licence valid). I have also mingw64 installed, but for a test it's fine.
Then I copy-paste the code into a file main.cpp, and build it:
mex -client engine main.cpp
A file main.exe is created, and on command line is output:
Building with 'Microsoft Visual C++ 2017'.
MEX completed successfully.
All seems fine.
Now, I copy-paste the dlls libMatlabDataArray.dll and libMatlabEngine.dll in the same folder, and when I run the program, I don't get the normal output, there is the exception "The specified module could not be found".
I think that I miss something but I cannot figure out what is my mistake.

回答(1 个)

Maneet Kaur Bagga
Maneet Kaur Bagga 2023-9-27
编辑:Maneet Kaur Bagga 2023-9-27
Hi Damien,
As per my understanding to troubleshoot the error please refer to the following steps:
  • Verify that the system's PATH environment variable contains the path to the MATLAB Runtime libraries. Look for the path to the MATLAB Runtime libraries (libMatlabDataArray.dll and libMatlabEngine.dll) in the output. Please check this by opening a command prompt and running the following command:
"echo %PATH%"
  • Try configuring MEX to use MinGW before building your client program with "mex -client engine main.cpp." This will explicitly set the compiler to MinGW and may help resolve any compatibility issues. Please refer to the MATLAB Answer mentioned below to configure MinGW as default compiler.
  • Ensure that all the necessary DLLs are present in the same folder as the main.exe file. Apart from "libMatlabDataArray.dll" and "libMatlabEngine.dll", there might be additional dependencies of the main.exe file which might be missing.
Configure MinGW Compiler
If none of the above steps work, please contact MathWorks Technical Support
Hope this helps!
Regards
Maneet Bagga

标签

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by