Clear Filters
Clear Filters

Matlab coder unable to compile MEX function with MinGW64 Compiler

9 views (last 30 days)
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 Comments
Marco Montanaro
Marco Montanaro on 1 Jul 2022
Edited: Marco Montanaro on 1 Jul 2022
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!

Sign in to comment.

Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!