Why is MATLAB R2017a unable to locate build file with a "NMAKE : fatal error U1052: file 'MODELNAME.mk' not found" error when using Visual Studio 2017?

15 ビュー (過去 30 日間)
Why is MATLAB R2017a unable to locate build tool for Visual Studio 2017?
For example, when building the 'vdp' model it throws the following error messages:
NMAKE : fatal error U1052: file '<http://vdp.mk/ vdp.mk>' not found
Stop.
The make command returned an error of 2
'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command,
operable program or batch file.
### Build procedure for model: 'vdp' aborted due to an error.
Error(s) encountered while building "vdp":
### Failed to generate all binary outputs.
Caused by:
Validation error(s):
### Validating other build tools ...
Unable to locate build tool "Microsoft Visual C Compiler": cl
Unable to locate build tool "Microsoft Visual C Linker": link
Unable to locate build tool "Microsoft Visual C++ Compiler": cl
Unable to locate build tool "Microsoft Visual C++ Linker": link
Unable to locate build tool "Microsoft Visual C/C++ Archiver": lib
Unable to locate build tool "NMAKE Utility": nmake
Component:Simulink | Category:Block diagram error
The reproduction steps as follow:
1. Set up MEX compiler as 'Microsoft Visual C++ 2017 (C)' by executing the command below at MATLAB Command Window:
>> mex -setup
Select the 'Microsoft Visual C++ 2017 (C)'.
2. Execute the following command at MATLAB Command Window to a model:
>> rtw_build('rtwdemo_abstime')
3. The model will generate code and then fail at the make stage as shown above.
This will affect all functionalities that require code generation like Rapid Accelerator mode, etc.

採用された回答

MathWorks Support Team
MathWorks Support Team 2018 年 1 月 18 日
Microsoft recently changed Visual Studio 2017 behavior to set the current folder to a default directory when any Developer tools are run.
When 'model.bat' calls 'vcvarsall.bat', it will change the current folder to the default directory which is not the 'model_grt_rtw' directory. Thus, 'nmake' will not be able to find 'model.mk' file.
Refer to Bug Report 1649009 for additional information.
As discussed in the above Bug Report, the temporary fix is to set an environment variable in MATLAB by executing the command below at MATLAB Command Window:
>> setenv('VSCMD_START_DIR','%CD%')
Add this to matlabrc to ensure it is set at startup. This will result in successful builds. However, this may cause a harmless 'project path cannot be found' message during build.
This bug was fixed as of <https://www.mathworks.com/downloads/web_downloads/download_update?release=R2017b&s_tid=ebrg_R2017b_1_1649009 R2017b Update 1>.
If you have a current subscription to MathWorks Software Maintenance Service (SMS), you can download the product updates. If not, learn more about <https://www.mathworks.com/services/maintenance/ MathWorks SMS>.

その他の回答 (0 件)

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by