[LLVMdev] raw_os_ostream: symbol not found

Trevor Harmon trevor.w.harmon at nasa.gov
Thu Apr 1 15:52:57 PDT 2010


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,

Trevor




More information about the llvm-dev mailing list