[LLVMdev] raw_os_ostream: symbol not found

Chris Lattner clattner at apple.com
Thu Apr 1 15:58:35 PDT 2010


On Apr 1, 2010, at 3:52 PM, Trevor Harmon wrote:

> Hi,
> 
> I'm writing some code that prints to std::ostream. However, it seems  
> that all of the LLVM objects can only print to llvm::raw_ostream, so I  
> can't do this:
> 
> void write(std::ostream &out) {
>    ...
>    for (BasicBlock::iterator i = block->begin(), e = block->end(); i ! 
> = e; ++i) {
>       Instruction *instruction = i;
>       out << *instruction << std::endl;
>       ...
>    }
>    ...
> }
> 
> I tried working around this problem using the raw_os_ostream adapter:
> 
>    #include <llvm/Support/raw_os_ostream.h>
>    ...
>    raw_os_ostream raw_out(out);
>    raw_out << *instruction << std::endl;
> 
> It compiles fine, but opt gives a runtime error when trying to load  
> the pass:
> 
>    Symbol not found: __ZTVN4llvm14raw_os_ostreamE
> 
> Any thoughts on why this is happening? And is there a workaround that  
> doesn't involve raw_os_ostream? Thanks,

It's hard to say: __ZTVN4llvm14raw_os_ostreamE is the vtable for raw_os_ostream.  This should be provided by lib/Support/raw_os_ostream.cpp.  Perhaps you're not linking in that .o file for some reason.  A workaround would be to use raw_ostream in your code instead of ostream :)

-Chris



More information about the llvm-dev mailing list