Undefined symbols for architecture x86_64: “std::terminate()”, when building kaleidoscope llvm

房东的猫 提交于 2019-12-07 02:46:26

std::terminate is located inside libc++ on OSX (which I assume you're using because of the "Cellar" in your path there). You appear to be explicitly linking against libc++ which means that the ordering is likely going wrong on your link line.

I can't duplicate this using the actual tutorial sources from top of tree (I don't have 3.6.1 checked out), but I'd suggest you follow the example Makefiles in there. The link line for a given part of the tutorial looks like:

clang++ -Wl,-dead_strip -rdynamic -Wl,-rpath -Wl,@executable_path/../lib -L/Users/echristo/builds/build-llvm/Debug+Asserts/lib -L/Users/echristo/builds/build-llvm/Debug+Asserts/lib -m64 -o /Users/echristo/builds/build-llvm/Debug+Asserts/examples/Kaleidoscope-Ch4 /Users/echristo/builds/build-llvm/examples/Kaleidoscope/Chapter4/Debug+Asserts/toy.o \ -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMProfileData -lLLVMInstCombine -lLLVMInstrumentation -lLLVMTransformUtils -lLLVMipa -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMExecutionEngine -lLLVMTarget -lLLVMAnalysis -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMMC -lLLVMCore -lLLVMSupport -lz -lpthread -ledit -lcurses -lm

which should give you an idea of what it'll look like.

From looking at your sources on github it looks like you've gone to a "include the output of llvm-config on the command line" which isn't very reliable as components may change, etc.

clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -o toy

from the tutorial should be enough to compile your simple example. Just replace toy.cpp with both of your example files since you split it up.

I got this error, while I was linking my code with my static lib built with ARC but there were some Objective C file with .mm extension. When I rename them with .m, worked fine.

SummonSkeletons

According to this you need to make sure your implementations for your functions all have corresponding declarations.

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