Undefined reference to `vtable for mlir::raw_indented_ostream'

I tried to convert a raw_ostream variable to raw_indented_ostream.

  auto outputFilename = "../output.c";
  std::string errorMessage;
  auto output = openOutputFile(outputFilename, &errorMessage);
  llvm::raw_ostream &os = output->os();
  raw_indented_ostream ros(os);

but got this error:

/usr/bin/ld: lib/libTianhe.a(TianheOps.cpp.o): in function `mlir::raw_indented_ostream::raw_indented_ostream(llvm::raw_ostream&)':
/root/polymer/llvm/install/include/mlir/Support/IndentedOstream.h:25: undefined reference to `vtable for mlir::raw_indented_ostream'
/usr/bin/ld: lib/libTianhe.a(TianheOps.cpp.o): in function `mlir::raw_indented_ostream::~raw_indented_ostream()':
/root/polymer/llvm/install/include/mlir/Support/IndentedOstream.h:23: undefined reference to `vtable for mlir::raw_indented_ostream'

the llvm I used is GitHub - llvm/Polygeist at 19da7eee184e4d715d9870fe866ac10858e874d1
I have no idea about how to fix it. Can anyone give me some help?

You probably didn’t link to libMLIRSupport

I linked libMLIRSupport to my project but got the same error.

I’m just telling you what this link error means: so you need to figure out which target is failing in your build because this particular link action is missing the library I mentioned earlier.

I got it. The llvm version I used didn’t compile the IndentedOstream.h/.cpp file. Thanks so much!