[cfe-dev] How do I output to the console in Windows using clang++?

NAKAMURA Takumi geek4civic at gmail.com
Fri Nov 18 19:12:53 PST 2011


Sean,

It is llvm issue rather than clang. please subscribe llvmdev, too.

2011/11/19 Sean McBeth <daedalic at gmail.com>:
> This seems like it should be simple, but I've run into quite a few problems
> with this. I first tried using cout from <iostream.h>, only to find out that
> llvm does not seem to support it. Then I tried using raw_ostream and the
> outs function, and now I'm getting an unresolved external error:
> "LLVM ERROR: Program used external function '_ZN4llvm4outsEv' which ciuld
> not be resolved!"
> Stack dump:
> 0.   Program arguments: lli test.bc
> 1.   Running pass: 'x86 Machine Code Emitter' on function '@main'
>
> To get the compiler to recognize outs, I had to modify the includes in
> raw_ostream.h to find a couple of files properly.
>
> Here is the code I'm using:
>
> #include "llvm/include/llvm/Support/raw_ostream.h"
>
> int main ()
> {
>     llvm::outs() << "HELLO WORLD";
> }
>
> I've gotten code to run just fine without using any library functions.

I assume you are running on mingw, and you try "lli blahblah.bc".

1) Try "configure --enable-optimized --enable-shared" (you would need
also --enable-embed-stdcxx)

2) Build all llvm libs as Bitcode manually, and link them together.
  (It would be harder)

...Takumi




More information about the cfe-dev mailing list