Question

There is a tutorial - http://llvm.org/docs/GettingStartedVS.html Example done in pure C. I can compile and link it. Without problem, really. But I need C++, not pure C. And here the difficulties begin.

For clang++ I use string like

"C:\..> clang++ -c hello.cpp -emit-llvm -o hello.bc"

then:

"C:\..> llc -filetype=obj hello.bc"

and

"C:\..> link hello.obj -defaultlib:libcmt -out:hello.exe"

there I get 14 errors LNK2001: unresolved external symbol

So, I need some tips. What I do wrong?

//-----------------

hello.cpp:

#include < iostream >

int main()

{

    std::cout << "TEST\n" << std::endl;

    return 0;

}

//-----------------

OS: Windows7.

UPD: Main question: how from .bc get .exe? (LLVM, Windows7)

Was it helpful?

Solution

You can use my GCC and Clang packages:

Download and extract them to the same directory. Clang will use GCC 4.6.3's libstdc++ and MinGW-w64's CRT. Call it like you would gcc.

Clang/LLVM cannot currently work with MSVC's C++ library, due to ABI issues. GCC's libstdc++ works quite well, though it has holes in surprising places (like std::to_string, <regex>, and <thread>).

Clang's Windows support is OK, but far from complete. You cannot for example dllexport whole C++ classes, unfortunately. And Win64 code generation is also not good enough to have a working C++ install (even in combination with GCC, like for 32-bit).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top