Simulink issuing bad command when attempting to build mex file
1 view (last 30 days)
Show older comments
I'm upgrading a model from Simulink 2020b to 2022b and ran into a problem with a mex build failure. I've simplified the model and attached: example_mex_failure.slx.
If I run the command from the windows command prompt:
> "C:\Program Files\MATLAB\R2022b\bin\win64\mex.exe" -R2018a -silent LD="$MINGWROOT\bin\g++" LDFLAGS="$LDFLAGS ""C:\Program Files\MATLAB\R2022b\bin\win64\libmwdsp_halidesim.dll"" ""C:\Program Files\MATLAB\R2022b\bin\win64\libmwdsp_halidesim.dll""" -output example_mex_failure_sfun.mexw64 @example_mex_failure_sfun.mol
The build of the mex file completes successfully, but please note this differs from the command Matlab attempts:
> "C:\Program Files\MATLAB\R2022b\bin\win64\mex.exe" -R2018a -silent LD="$MINGWROOT\bin\g++" LDFLAGS="$LDFLAGS "C:\Program Files\MATLAB\R2022b\bin\win64\libmwdsp_halidesim.dll" "C:\Program Files\MATLAB\R2022b\bin\win64\libmwdsp_halidesim.dll"" -output example_mex_failure_sfun.mexw64 @example_mex_failure_sfun.mol
Matlab's command seems to omit escaping the nested quotation marks when building a mex file on "Normal" simulations.
0 Comments
Accepted Answer
Shubham
on 5 Apr 2023
Hi Marshall,
Based on the information you have provided, it seems like the issue might be related to the way quotation marks are being handled by Matlab's mex command when building the mex file for "Normal" simulations. It appears that Matlab is not properly escaping the nested quotation marks in the command, leading to a build failure.
One possible workaround for this issue could be to use single quotes instead of double quotes to enclose the paths to the libraries in the mex command. For example, you could try the following command:
mex -R2018a -silent LD="$MINGWROOT\bin\g++" LDFLAGS="$LDFLAGS 'C:\Program Files\MATLAB\R2022b\bin\win64\libmwdsp_halidesim.dll' 'C:\Program Files\MATLAB\R2022b\bin\win64\libmwdsp_halidesim.dll'" -output example_mex_failure_sfun.mexw64 @example_mex_failure_sfun.mol
This command should properly enclose the library paths in single quotes, which should be interpreted correctly by the mex compiler. Note that I have also removed the duplicated path to the libmwdsp_halidesim.dll library in the command.
Another possible workaround could be to use the -argcheck option with the mex command to enforce strict argument checking, which might help identify any issues with how quotation marks are handled in the command. For example, you could try the following command:
mex -R2018a -silent -argcheck LD="$MINGWROOT\bin\g++" LDFLAGS="$LDFLAGS ""C:\Program Files\MATLAB\R2022b\bin\win64\libmwdsp_halidesim.dll"" ""C:\Program Files\MATLAB\R2022b\bin\win64\libmwdsp_halidesim.dll""" -output example_mex_failure_sfun.mexw64 @example_mex_failure_sfun.mol
This command should enable strict argument checking, which might help identify any issues with how quotation marks are handled in the command.
I hope these suggestions help resolve the issue you are facing with the mex build failure.
2 Comments
More Answers (0)
See Also
Categories
Find more on MATLAB Compiler 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!