3

Currently I am building a model for Simulink Real-Time and have Microsoft Visual C++ Compilers Community 2015 as my compiler for Simulink Real-Time. When I try to build my model it gives the following error:

### Linking ... 
    link.exe /nologo /dll /MANIFEST /OPT:NOREF /export:mexFunction /OUT:Test_Handler_sfun.mexw64 /map:"Test_Handler_sfun.map"      @Test_Handler_sfun.mol 
LINK : fatal error LNK1104: cannot open file 'ucrt.lib' 
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Bin\amd64\link.exe"' : return code '0x450' 
Stop.

Previously I also had this error, which is caused by the same problem I believe. I solved this in an very unelegant manner.

 C1083: Cannot open include file: 'stddef.h': No such file or directory 

I have searched quite a bit on google. I found out that this is because of some files and/or libraries are now located in the Windows 10 SDK installation folder (C:\Program Files (x86)\Windows Kits\10) and that this path is not included in the compiler somehow. There are quite some solutions for when you are working in a Visual Studio project, but not when working with Matlab and or Simulink.

How do I make sure that the libraries and files can be found and opened by the compiler?

ProjectM
  • 31
  • 1
  • 3

2 Answers2

3

My answer is rather for Windows 8.1 and VS2017. For me worked using the Visual Studio Installer (in All Programs) and modifying Desktop development with C++ by adding Windows 8.1 SDK and UCRT SDK. The library was picked up automatically then.

Reference screenshot:

Visual Studio Installer

Raf
  • 570
  • 6
  • 13
2

Since you solved the missing header file in an "unelegant matter" I am going to suggest another unelegant solution to your current problem. I had the same problem, and adding the corresponding library path (-L... to the compile options helped:

mex -output mybinary 
    -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt"
    -L"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64"

Make sure to adjust it to the exact version of your Windows Kit (10.0.10240.0 in my case), and target (x64).

Jan W
  • 143
  • 1
  • 10