简体   繁体   中英

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

I am trying to follow http://gnuu.org/2009/09/18/writing-your-own-toy-compiler tutorial. I am getting the following error.

What am I missing?

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

You're missing a couple of things.

  1. You're missing the fact that the compiler's first warning message is informing you of an obvious bug in your code. You will need to fix that.

  2. Your compiler's second warning message informs you of another possible bug in your code.

  3. Finally, you're missing the -c option to g++ , resulting in the compiler attempting to link an incomplete program, instead of generating an object module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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