gpt4 book ai didi

c++ - ld : symbol(s) not found for architecture x86_64 error

转载 作者:行者123 更新时间:2023-11-28 00:01:00 27 4
gpt4 key购买 nike

我正在尝试关注 http://gnuu.org/2009/09/18/writing-your-own-toy-compiler教程。我收到以下错误。

我错过了什么?

Invoking: GCC C++ Compiler
g++ -std=c++0x -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -I/usr/local/opt/llvm/include -O0 -g3 -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -std=c++11 -fPIC -MMD -MP -MF"src/main.d" -MT"src/main.o" -o "src/main.o" "../src/main.cpp"
In file included from ../src/main.cpp:2:
../src/node.h:17:61: warning: control reaches end of non-void function [-Wreturn-type]
virtual llvm::Value* codeGen(CodeGenContext& context) { }
^
../src/node.h:63:19: warning: field 'rhs' will be initialized after field 'op' [-Wreorder]
lhs(lhs), rhs(rhs), op(op) { }
^
2 warnings generated.
Undefined symbols for architecture x86_64:
"yyparse()", referenced from:
_main in main-974049.o
"_programBlock", referenced from:
_main in main-974049.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [src/main.o] Error 1

最佳答案

您遗漏了几件事。

  1. 您忽略了编译器的第一条警告消息通知您代码中存在明显错误这一事实。你需要解决这个问题。

  2. 您的编译器的第二条警告消息通知您代码中可能存在另一个错误。

  3. 最后,您缺少 g++-c 选项,导致编译器尝试链接不完整的程序,而不是生成目标模块.

关于c++ - ld : symbol(s) not found for architecture x86_64 error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38934895/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com