필터 지우기
필터 지우기

Simulink issuing bad command when attempting to build mex file

조회 수: 4 (최근 30일)
Marshall
Marshall 2023년 1월 20일
댓글: Shubham 2023년 4월 7일
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