4

From the Wikipedia articles on Clang and LLVM, and from the LLVM and Clang website, my understanding is that if LLVM is installed then a complete set of a compiler (LLVM) and its front end (Clang) are installed. I installed LLVM 4.0 on Windows 10 64bit and tried to compile the following simple program:

#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
    cout << "\nBuilt with Clang on Windows!\n" << endl;

    return 0;
}

But I got this error message:

clang++ main.cpp -o main
main.cpp:2:10: fatal error: 'iostream' file not found
#include <iostream>
         ^~~~~~~~~~
1 error generated.

Is my understand correct of what LLVM and Clang are? If yes, what did I miss? If no, how do I compile on Windows using these tools?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Amani
  • 16,245
  • 29
  • 103
  • 153
  • 1
    You have the compiler. Where is your standard library implementation? – Lightness Races in Orbit Jun 28 '17 at 00:30
  • @BoundaryImposition, My understanding is that a compiler should have the standard library (C++ in this case) as part of it, right? If not then where do I get one? Is there a separate download I need to do? – Amani Jun 28 '17 at 00:33
  • @BoundaryImposition, could you please point me to what exactly I should do to solve my problem? Please. I'm learning. – Amani Jun 28 '17 at 00:37
  • Don't know where you heard that; a compiler, a linker and a stdlib are separate things. [Step 8](https://clang.llvm.org/get_started.html) gives you a clue as to how it works (albeit for the wrong OS). Just read the relevant documentation for your platform. – Lightness Races in Orbit Jun 28 '17 at 00:38
  • Possible duplicate of https://stackoverflow.com/q/32239122/560648 (3rd Google result for `clang C++ install`!) – Lightness Races in Orbit Jun 28 '17 at 00:39
  • 1
    @BoundaryImposition, before asking I went through the question you linked and the blog as well and could not succeed to make it work. Step 8 and I understood it talks of if one is compiling Clang from scratch, I just downloaded LLVM, the download which includes Clang. Adding MinGW-64 bin and libstdc++ directories to the path does nod solve the problem either. Do you have any idea on how to make LLVM/Clang see the libstdc++? – Amani Jun 28 '17 at 00:57
  • https://stackoverflow.com/questions/26333823/clang-doesnt-see-basic-headers – sailfish009 Jun 28 '17 at 00:58
  • A *compiler* is just one component of a C++ *implementation*. Another component, which you seem to be missing, is the runtime library, which includes both headers like `` and executable code in some form that implements the functions. – Keith Thompson Jun 28 '17 at 01:42

0 Answers0