Garmaine Staff asked 1 year ago

I'm trying to use the llvm framework to output formatted text using the llvm::formatv() function.

E.g. I want to output a double to a llvm raw_ostream, basically using this code:

someStream << llvm::formatv("{0}", someDouble);

I think, that I'm including the right headers for this to work, obviously I need both llvm/Support/raw_ostream.h and llvm/Support/FormatVariadic.h. Additionally I tried to include other headers, like e.g. llvm/Support/FormatAdapters.h.

Unfortunately I'm getting the following error, when I try to build:

Undefined symbols for architecture x86_64:
  "typeinfo for llvm::detail::format_adapter", referenced from:
      typeinfo for llvm::detail::provider_format_adapter<double> in libjuiceDiagnostics.a(Diagnostics.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What could be the problem? Unfortunately the llvm documentation didn't help me with this problem.

If it matters, I'm linking the llvm libraries like this in my CMakeLists.txt:

set(LLVM_CONFIG_CMD "${LLVM_INSTALL_DIR}/bin/llvm-config")
execute_process(COMMAND ${LLVM_CONFIG_CMD} --libfiles

target_link_libraries(myTarget ${LLVM_LIBS})

Therefore no library should be missing.