[LLVMdev] LLVM: C++ -> C
Dale Johannesen
dalej at apple.com
Tue Sep 29 09:48:03 PDT 2009
On Sep 29, 2009, at 9:37 AM, dilas dilas wrote:
> 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.
> 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?
>
>
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list