Simulink issuing bad command when attempting to build mex file

1 次查看(过去 30 天)
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.

采纳的回答

Shubham
Shubham 2023-4-5
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 个评论
Marshall
Marshall 2023-4-5
Thanks Shubham.
To elaborate on the workaround I'm using, edit a file at ...\R2022b\toolbox\stateflow\coder\private\code_interface_and_support_files.m to parse for the improper escape quotation mark condition and fix it (example attached).
I just figured this was an issue MathWorks would want to be aware of to fix in a future release.
Shubham
Shubham 2023-4-7
Thanks Marshall and this issue will surely be fixed in a future release.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by