Linking against clang-llvm

落花浮王杯 提交于 2019-12-04 07:52:33

When I've built some stuff against llvm / clang, this is what I've used to build it. Perhaps you can compare the two build lines.

Also, the llvm-config command I've used has been: llvm-config --cxxflags --ldflags --libs backend.

Finally, this is likely partially related to an ordering issue. You probably want to include the libraries for llvm before you include the clang libraries.

/usr/bin/g++                                                              \
    -fno-exceptions -fno-rtti -fno-common                                 \
    -I/Users/wlynch/Homebrew/include                                      \
    -DNDEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS \
    ../src/main.cpp -c -o src/main.cpp.0.o

/usr/bin/g++
     src/main.cpp.0.o -o /Users/wlynch/Dropbox/Clang/Indexer/build/main               \
     -L/Users/wlynch/Homebrew/lib -L/Users/wlynch/Homebrew/lib                        \
     -lpthread -lm                                                                    \
     -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG     \
     -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine \
     -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore            \
     -lLLVMX86AsmPrinter -lLLVMMC -lLLVMX86Info -lLLVMSupport -lLLVMSystem            \
     -lclangAST -lclangAnalysis -lclangBasic -lclangChecker -lclangCodeGen            \
     -lclangDriver -lclangFrontend -lclangFrontendTool -lclangIndex -lclangLex        \
     -lclangParse -lclangRewrite -lclangSema -lclangSerialization

I assume you have back quotes around ~/bin/llvm-config, right?

That being said, move the -l options and the

`~/bin/llvm-config --cxxflags --ldflags --libs`

after the .o files on the command line. Stuff won't be taken out of the libraries unless referenced by a preceding object file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!