Message Boards Message Boards

GROUPS:

How is WM 11.3 set to C++ compiler from Visual Studio 2017

Posted 3 years ago
5748 Views
|
3 Replies
|
2 Total Likes
|

I have not been able to get to work any of the Documentation CCompiler examples. My Windows 10 machine WM recognizes the compiler, but nothing is compile. FOr example. I am getting a following compilation error at end CreateLibrary::cmperr: Compile error: C:\Program Files\Wolfram Research\Mathematica\11.3\SystemFiles\IncludeFiles\C\WolframLibrary.h(24): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory

In[1]:= Needs["CCompilerDriver`"]
CCompilers[]
demoFile = 
  FileNameJoin[ {$CCompilerDirectory, "SystemFiles", "CSource", 
    "createDLL_demo.c"}];

Out[2]= {{"Name" -> "Visual Studio", 
  "Compiler" -> 
   CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler, 
  "CompilerInstallation" -> 
   "C:\\Program Files (x86)\\Microsoft Visual \
Studio\\2017\\Community", "CompilerName" -> Automatic}}

In[6]:= "Compiler" /. {{"Name" -> "Visual Studio", 
   "Compiler" -> 
    CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler, 
   "CompilerInstallation" -> 
    "C:\\Program Files (x86)\\Microsoft Visual \
Studio\\2017\\Community", "CompilerName" -> Automatic}}

Out[6]= {CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler}

In[7]:= CreateLibrary[demoCString, "testDLL"]
$CCompilerDefaultDirectory


Out[7]= CreateLibrary[demoCString, "testDLL"]

Out[8]= "C:\\Users\\user\\AppData\\Roaming\\Mathematica\\SystemFiles\\\
LibraryResources\\Windows-x86-64"

In[9]:= SystemOpen["C:\\Users\\user\\AppData\\Roaming\\Mathematica\\\
SystemFiles\\LibraryResources\\Windows-x86-64"]

In[10]:= Needs["SymbolicC`"];

In[11]:= fun1 = CFunction[{"int"}, "fun1", {}, CBlock[{CReturn[0]}]];
funStr1 = ToCCodeString[fun1]

Out[12]= "int fun1()
{
return 0;
}
"

In[13]:= demoFile = 
  FileNameJoin[ {$CCompilerDirectory, "SystemFiles", "CSource", 
    "createDLL_demo.c"}];

In[14]:= CreateLibrary[{demoFile}, "testLib", 
 "ShellOutputFunction" -> Print]

During evaluation of In[14]:= 
C:\Users\user\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Windows-x86-64\Working-asus-1468-6472-1>call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.6.7
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Microsoft (R) C/C++ Optimizing Compiler Version 19.13.26132 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

createDLL_demo.c
C:\Program Files\Wolfram Research\Mathematica\11.3\SystemFiles\IncludeFiles\C\WolframLibrary.h(24): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory

During evaluation of In[14]:= CreateLibrary::cmperr: Compile error: C:\Program Files\Wolfram Research\Mathematica\11.3\SystemFiles\IncludeFiles\C\WolframLibrary.h(24): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory

Out[14]= $Failed
3 Replies

It is available in both, actually. The component is called "Windows 8.1 SDK and UCRT SDK"

enter image description here

Thanks for your reply. Is this option ound under the Visual Studio Community 2017 installation or under the VOsual Studio Built tools?

enter image description here

Make sure the "Universal CRT SDK" component is selected when installing Visual Studio.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract