构建万花筒llvm时,架构x86_64的未定义符号:"std :: terminate()" [英] Undefined symbols for architecture x86_64: "std::terminate()", when building kaleidoscope llvm

查看:123
本文介绍了构建万花筒llvm时,架构x86_64的未定义符号:"std :: terminate()"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做万花筒教程.我正在第二步.

I'm doing the kaleidoscope tutorial. I'm on step two.

https://github.com/westymatt/creole

但是用clang ++编译时会出现此错误

But I get this error when building with 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位于OSX的libc ++内部(由于那里的路径中有地窖",所以我假设您正在使用它).您似乎已明确链接到libc ++,这意味着链接行上的排序可能有误.

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.

我不能从树的顶部使用实际的教程源来重复此操作(我没有检出3.6.1),但是我建议您按照此处的示例Makefiles进行操作.本教程给定部分的链接行如下所示:

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

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.

从github上查看源代码后,您似乎已经进入在命令行中包含llvm-config的输出",因为组件可能会发生变化,这并不是很可靠.

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

教程中的

应该足以编译您的简单示例.拆分后,只需用两个示例文件替换toy.cpp.

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.

这篇关于构建万花筒llvm时,架构x86_64的未定义符号:"std :: terminate()"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆