LLVM: C++ -> C

I've read that LLVM can convert from C++ to C code.
So I've used it in such a way:
I'm Windows-user so I used MinGW.
I employed this file as the test:

llvm-hello.cpp:

#include <iostream>

int main(int argc, char* argv[])
{
  system("pause");
  return 0;
}

result of "llvm-g++ C:\llvm_hello.cpp -o C:\llvm_hellopp.exe" worked just fine.

as a result of "llvm-g++ -O3 -emit-llvm C:\llvm_hello.cpp -c -o C:\llvm_hellopp.bc" and
"llc -march=c C:\llvm_hellopp.bc -o C:\llvm_helloCppToC.c" I obtained this charming stuff:
http://codepaste.ru/2409/
And after "llvm-gcc C:\llvm_helloCppToC.c -o C:\llvm_helloCppToC.exe"
I've got:
"C:\llvm_helloCppToC.c: In function 'main':
C:\llvm_helloCppToC.c:180: warning:return type of 'main' is not 'int'
C:\...\Temp/ccfREe4x.o:fake:(.text+0xae): undefined reference to 'std::ios_base::Init::Init()'
C:\...\Temp/ccfREe4x.o:fake:(.text+0xbe): undefined reference to 'std::ios_base::Init::~Init()'
collect2: ld returned 1 exit status"
What I've done wrong?

I've read that LLVM can convert from C++ to C code.

It does, but it does not supply a C++ library. You'll need to do that.

C:\...\Temp/ccfREe4x.o:fake:(.text+0xae): undefined reference to 'std::ios_base::Init::Init()'
C:\...\Temp/ccfREe4x.o:fake:(.text+0xbe): undefined reference to 'std::ios_base::Init::~Init()'
collect2: ld returned 1 exit status"
What I've done wrong?

You need to link with C++ standard library. Either use llvm-g++ as
linker, or add -lstdc++

dilas dilas <espiritusantu@mail.ru> writes:

And after "llvm-gcc C:\llvm_helloCppToC.c -o C:\llvm_helloCppToC.exe"

C:\...\Temp/ccfREe4x.o:fake:(.text+0xae): undefined reference to 'std::ios_base::Init::Init()'

You are not linking against your C++ standard library which contains
the implementation of std::ios_base::Init. Try using g++ to link the
file (it should link C++ libraries by default).

Right, also be aware of:
http://llvm.org/docs/FAQ.html#translatecxx

in particular, the caveats at the end.

-Chris