I was trying to link LLVM with My C++ project for the past two days and it's finally working but the issue is when i use dump()
method it gives a linker error i thought the problem is with the libraries that i'm linking against, so i've linked my executable against all the LLVM libraries(modules) but with no success. so is that a bug in the LLVM5.0 code base or am i doing something wrong and the reason i'm specifically speaking about LLVM5.0 because i've read else where (LLVM-5.0 Makefile undefined reference fail) in the comment section that there was no issue compiling the same code using LLVM4.0 and of course i've searched about other solution but there's nothing
llvm_test.cpp:
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
llvm::LLVMContext context;
int main(){
llvm::Module*module = new llvm::Module("llvm-module",context);
module->dump();
}
commands:
clang++ -O3 -Wall -std=c++11 `llvm-config --cppflags --ldflags` `llvm-config --libs core --system-libs` toy.cpp
and about that i have linked against all modules:
clang++ -O3 -Wall -std=c++11 `llvm-config --cxxflags --ldflags` `llvm-config --libs all --system-libs` toy.cpp
compiler: Apple Clang 8.0.0 x86_64
OS: mac OS 10.12.5
thanks for any help in advance
OK, I looked into the code of llvm and you can actually do it far easier. All you have to do is stop using dump and instead:
module->print(llvm::errs(), nullptr);
Which is exactly what dump does internally.