9

I have installed LLVM and Clang-3.9.0 on Win10. I have MinGW installed as well.

I have put my C code in 'D:' drive.

I can use gcc and g++ to compile my code. But when I use clang I get:

clang -cc1 version 3.9.0 based upon LLVM 3.9.0 default target x86_64-pc-windows-msvc
ignoring duplicate directory "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A"
ignoring duplicate directory "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A"
#include "..." search starts here:
#include <...> search starts here:
 C:\Program Files\LLVM\bin\..\lib\clang\3.9.0\include
 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
 C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A
End of search list.
 hello.c:1:10: fatal error: 'stdio.h' file not found
 #include "stdio.h"
             ^
 1 error generated.

As I can use gcc and g++, my environment variable settings are right. But then I am not able to force clang to look into C:\MinGW.

I tried copy pasting the whole MinGW folder manually in C:\Program Files\LLVM\bin\ and \lib\clang\3.9.0\include separately, but it did not work. I wanted to try this, but in 3.9.0 I cannot find, clang/lib/Frontend/InitHeaderSearch.cpp.

Anyway, is there a work around?

Note: I have tried <stdio.h> and "stdio.h" both, and I still get the same error.

Community
  • 1
  • 1
algoProg
  • 718
  • 2
  • 11
  • 27
  • Does `stdio.h` exist in any of the search paths listed for `<...>`? – jamesdlin Oct 11 '16 at 01:42
  • Actually it does not. AFAIK, clang/++ is not shipped with c/c++ libs. That's why I am trying to change the path for clang to look in to. – algoProg Oct 11 '16 at 01:45
  • Can you just add an appropriate path to the `INCLUDE` environment variable then? – jamesdlin Oct 11 '16 at 01:51
  • Hi can you please explain your solution? Also, the thread you have mentioned is good for Clang version < 3.6. 3.7 onwards things have changed. – algoProg Oct 11 '16 at 01:56
  • I'm suggesting that you try setting an environment variable named `INCLUDE` whose value is the path to the appropriate directory with your (hopefully clang-compatible) standard header files. – jamesdlin Oct 11 '16 at 01:59
  • I have found the solution. I will post it now. I missed some things and it is so easy!! – algoProg Oct 11 '16 at 02:02
  • Do not mark this as a duplicate question! the answer suggested in other question does not apply!!! – algoProg Oct 11 '16 at 02:38
  • Indeed. I have nominated this for reopening. – Engineer May 06 '17 at 05:20
  • The [post here](https://stackoverflow.com/questions/39871656/how-to-use-clang-with-mingw-w64-headers-on-windows/47148323#47148323) are the correct way to go. – jdhao Mar 29 '18 at 14:21

1 Answers1

3

Okay, so until now things with Clang/LLVM in Windows. Starting 3.7 or so things have changed: Clang/LLVM binaries are built with Visual Studio and for Visual Studio. No need for MinGW, as far as I understand.

So now install LLVM via the binary files available. Make sure that you have VS2015 (or 2013 and more) previously installed. When LLVM is being installed add it in the path when prompted.

Now after all that has been done, start the developer commander prompt for VS2015 (got to start -> Visual Studio 2015 -> Developer Commander Prompt for VS2015. I guess, you will choose whatever suits for your requirements). Now from here try using the clang commands listed on LLVM website.

However commands like lli, llvm-dis and llc still cannot be ran.

Also, LLVM website still says that GNU tools for windows are needed. But I do not know what for!

algoProg
  • 718
  • 2
  • 11
  • 27