필터 지우기
필터 지우기

Matlab coder unable to compile MEX function with MinGW64 Compiler

조회 수: 9 (최근 30일)
Marco Montanaro
Marco Montanaro 2022년 7월 1일
편집: Marco Montanaro 2022년 7월 1일
Hello, I am trying to compile a Mex function for a model I've created, but for some reason despite updating, configuring and managing the MinGW compiler for Matlab, I cannot seem to get it working properly anymore.
I start up Matlab Codegen, run through the requested steps, but Matlab keeps failing at the "Check for Run-Time Issues" part when it has to generate a Mex. More specifically this is the error I get:
[291/291] C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin\gcc @SDM_main_mex.mexw64.rsp -m64 -Wl,--no-undefined -shared -static -L"C:\Program Files\MATLAB\R2020b\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -o "SDM_main_mex.mexw64" -llibemlrt -llibcovrt -llibut -llibmwmathutil "C:/Users/marco/Dropbox/RFI - SDM Marco/SDM/Modelli\BaseSw.lib" "ws2_32.lib" "C:/Users/marco/Dropbox/RFI - SDM Marco/SDM/Modelli\CFM.lib" "C:/Users/marco/Dropbox/RFI - SDM Marco/SDM/Modelli\SFM.lib" -Wl,--version-script,SDM_main_mex.map
FAILED: SDM_main_mex.mexw64 
C:\ProgramData\MATLAB\SupportPackages\R2020b\3P.instrset\mingw_w64.instrset\bin\gcc @SDM_main_mex.mexw64.rsp -m64 -Wl,--no-undefined -shared -static -L"C:\Program Files\MATLAB\R2020b\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -o "SDM_main_mex.mexw64" -llibemlrt -llibcovrt -llibut -llibmwmathutil "C:/Users/marco/Dropbox/RFI - SDM Marco/SDM/Modelli\BaseSw.lib" "ws2_32.lib" "C:/Users/marco/Dropbox/RFI - SDM Marco/SDM/Modelli\CFM.lib" "C:/Users/marco/Dropbox/RFI - SDM Marco/SDM/Modelli\SFM.lib" -Wl,--version-script,SDM_main_mex.map
gcc: error: ws2_32.lib: No such file or directory
ninja: build stopped: subcommand failed.
I have tried running it on both R2020b and R2021b, I've followed the steps present in https://www.mathworks.com/matlabcentral/answers/313298-i-already-have-mingw-on-my-computer-how-do-i-configure-it-to-work-with-matlab as well to no avail. I don't really get why it suddenly refuses to cooperate anymore, as I was previously able to generate Mex functions no problem.
  댓글 수: 4
Walter Roberson
Walter Roberson 2022년 7월 1일
You need VS2019 instead of VS2022
Marco Montanaro
Marco Montanaro 2022년 7월 1일
편집: Marco Montanaro 2022년 7월 1일
Worked like a cinch! I should also add to this though that the issue seems to be something that also relates to Matlab R2021b. Running Codegen with Matlab R2020b + VisualStudio 2019 fixed it! Thanks!

댓글을 달려면 로그인하십시오.

답변 (0개)

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by