How can I tell MMA where to find c header files for compilation? CreateLibrary is returning C1083 can't find stddef.h. Details follow...
Windows 10 - 1709 using Visual Studio 2015 (Community Edition, update 3), having modified VisualStudioCompiler.m to reference VS 2015)
by modding Line 280 to
$VisualStudioVersions = {"2015", "2013", "2012", "2010", "2008", "2005"}
and adding
installPath["2015"] := installPathFromEnvironment["VS140COMNTOOLS"]
Compiling generally works; the problem is with creating a library. Specifically the example in the documentation at CCompilerDriver/ref/CreateLibrary.
After
Needs["CCompilerDriver`"]
The documentation example continues with
add1src = "
#include \"WolframLibrary.h\"
When the final library creation input
add1lib = CreateLibrary[add1src, "add1"]
is executed the result is
"Compile error: "C:\ Program Files \ Wolfram Research \ \ Mathematica \ 11.0\ SystemFiles \ IncludeFiles \ C \ \ WolframLibrary.h(24): fatal error C1083: Cannot open include file: \ 'stddef.h': No such file or directory "
Now. the opening lines of WolframLibrary.h are:
#ifndef WOLFRAMLIBRARY_H
#define WOLFRAMLIBRARY_H
#include "setjmp.h"
#define WolframLibraryVersion 3
#if !(defined(MATHEMATICA_KERNEL) || defined(MATHEMATICA_RUNTIME))
#include <stddef.h>
#include "dllexport.h"
#include "extern.h"
So it is < stddef.h > which can't be found.
Now, in Visual Studio unders Windows 10, sttdef.h is to be found in e.g.
C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\km\crt
(there are several, other subfolders of Include are 10.0. {14393, 10586,102140, 10150})
My questions are:
1/ Where does MMA look for e.g. stddef.h, i.e. where is the path specified
2/ How can I tell MMA to look in a location I specify, such as above
Many thanks!
Extra Information per Szabolcs' suggestion
After "ShellCommandFunction" -> Print, "ShellOutputFunction" -> Print
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
cl.exe /LD /O2 /MT /I "C:\Program Files\Wolfram Research\Mathematica\11.0\SystemFiles\IncludeFiles\C" /I "C:\Program Files\Wolfram Research\Mathematica\11.0\SystemFiles\Links\MathLink\DeveloperKit\Windows-x86-64\CompilerAdditions\mldev64\include" "C:\Users\Julian\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Windows-x86-64\Working-lotan-8708-15120-1\add1.c" /link /implib:"C:\Users\Julian\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Windows-x86-64\Working-lotan-8708-15120-1\add1.lib" /LIBPATH:"C:\Program Files\Wolfram Research\Mathematica\11.0\SystemFiles\Links\MathLink\DeveloperKit\Windows-x86-64\CompilerAdditions\mldev64\lib" /LIBPATH:"C:\Program Files\Wolfram Research\Mathematica\11.0\SystemFiles\Libraries\Windows-x86-64" "ml64i4m.lib" /out:"C:\Users\Julian\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Windows-x86-64\Working-lotan-8708-15120-1\add1.dll"
C:\Users\Julian\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Windows-x86-64\Working-lotan-8708-15120-1>call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64 Copyright (C) Microsoft Corporation. All rights reserved.
add1.c C:\Program Files\Wolfram Research\Mathematica\11.0\SystemFiles\IncludeFiles\C\WolframLibrary.h(24): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory
"ShellCommandFunction" -> Print, "ShellOutputFunction" -> Print
(options toCreateLibrary
) and include it in the question. $\endgroup$