Test my build environment does not work

조회 수: 1 (최근 30일)
Damien Isebe
Damien Isebe 2022년 6월 3일
편집: Maneet Kaur Bagga 2023년 9월 27일
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