Loading a dialect in MLIR

I’m trying to build my own “mlir-opt”. So, I created a new file and followed the same steps that I observed in many examples of mlir dialects. As a result, I obtained a main function, as shown in the screenshot. However, I encountered an error when attempting to build my target (which is now adt-opt ), stating an undefined reference to mlir::adt::AdtDialect::AdtDialect(mlir::MLIRContext*). The thing is that, I included the .inc file where my dialect is defined(See the third screenshot), so I don’t understand from where this error comes.
Screenshot from 2023-06-14 15-36-06


Undefined reference are errors from the linker, not from the compiler. That means it isn’t about a missing include, but about a missing library or object file in the link: your main function is calling the dialect constructor, but the implementation of the dialect isn’t linked in. This hints to a missing dependency in CMake.

Yes, you’re right. In fact, I didn’t see firstly where the implementation of the dialect constructor was. So I included the #include “…/build/include/Adt/AdtOpsDialect.cpp.inc” file, and implemented the initialize() method for my dialect. And it works know.