简体   繁体   English

构建万花筒llvm时,架构x86_64的未定义符号:“ std :: terminate()”

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

I'm doing the kaleidoscope tutorial. 我正在做万花筒教程。 I'm on step two. 我正在第二步。

https://github.com/westymatt/creole https://github.com/westymatt/creole

But I get this error when building with clang++ 但是用clang ++构建时出现此错误

clang++ -Wno-c++11-extensions -g -std=c++11  -I/usr/local/Cellar/llvm/3.6.1/include    -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS src/lexer.cc src/parser.cc -L/usr/local/Cellar/llvm/3.6.1/lib/ -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMProfileData -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMX86Desc -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMMC -lLLVMX86Utils -lLLVMCore -lLLVMSupport -lc++ -O0 -o creole
Undefined symbols for architecture x86_64:
  "std::terminate()", referenced from:
      ___clang_call_terminate in lexer-608bbc.o
      ___clang_call_terminate in parser-09b617.o
ld: symbol(s) not found for architecture x86_64

std::terminate is located inside libc++ on OSX (which I assume you're using because of the "Cellar" in your path there). std :: terminate位于OSX上的libc ++内部(我假设您正在使用它,因为那里的路径是“地窖”)。 You appear to be explicitly linking against libc++ which means that the ordering is likely going wrong on your link line. 您似乎已明确链接到libc ++,这意味着链接行上的排序可能有误。

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. 我不能从树的顶部使用实际的教程源来重复此操作(我没有检出3.6.1),但是我建议您按照此处的示例Makefiles进行操作。 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 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 /调试+断言/ 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. 从github上的源代码看,您似乎已经进入了“在命令行中包含llvm-config的输出”,因为组件可能会发生变化,这并不是很可靠。

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. 拆分后,只需用两个示例文件替换toy.cpp。

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. 我将代码链接到使用ARC构建的静态库时遇到了此错误,但是有一些带有.mm扩展名的Objective C文件。 When I rename them with .m, worked fine. 当我用.m重命名它们时,工作正常。

根据这一点,您需要确保函数的实现都具有相应的声明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM