0

I am compiling with clang and linking to LLVM and it works in debug mode on -O0 but when I turn on optimizations I get:

Main-21ab48.o : error LNK2001: unresolved external symbol "public: void __cdecl llvm::cfg::Update<class llvm::BasicBlock *>::dump(void)const " (?dump@?$Update@PEAVBasicBlock@llvm@@@cfg@llvm@@QEBAXXZ)
Main-21ab48.o : error LNK2001: unresolved external symbol "public: void __cdecl llvm::cfg::Update<class llvm::BasicBlock *>::dump(void)const " (?dump@?$Update@PEAVBasicBlock@llvm@@@cfg@llvm@@QEBAXXZ)

I am using LLVM 15 and I compiled it myself. I found this definition in CFGUpdate.h

 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
   LLVM_DUMP_METHOD void dump() const { print(dbgs()); }
 #endif

I tried removing the header guards but that didn't help. Defining NDEBUG did but I am afraid that might be disabling some optimizations.

roCaP23
  • 21
  • 4
  • have you checked this [link](https://stackoverflow.com/questions/12184027/unresolved-external-symbol-public-thiscall) –  Aug 25 '22 at 09:34
  • If I understand correctly you're compiling an LLVM version you're linking against. When compiling LLVM, have you tried passing the flag with `-DLLVM_ENABLE_DUMP=ON` to `cmake` ? – jmmartinez Aug 26 '22 at 08:58

0 Answers0