orangeduck / BuildYourOwnLisp

Learn C and build your own programming language in under 1000 lines of code!
http://www.buildyourownlisp.com/
Other
2.93k stars 396 forks source link

Compile time error for Chapter 8's "error_handling.c" on OSX #88

Closed youfoundron closed 9 years ago

youfoundron commented 9 years ago

File is error_handling.c from chapter 8, mpc.c and mpc.h are in the local direcotry.

Compiling with cc -std=c99 -Wall error_handling.c -ledit -lm -v -o error_handling on OSX Yosemite (10.10.4) yields the following invocation:

Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.4.0
Thread model: posix
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.10.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name error_handling.c -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 242.2 -v -dwarf-column-info -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0 -Wall -std=c99 -fdebug-compilation-dir /Users/ron/Development/build-your-own-lisp/chpt_8 -ferror-limit 19 -fmessage-length 115 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/z6/jl998_mx7rz2s6l38795ygfr0000gq/T/error_handling-330a97.o -x c error_handling.c
clang -cc1 version 6.1.0 based upon LLVM 3.6.0svn default target x86_64-apple-darwin14.4.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o error_handling /var/folders/z6/jl998_mx7rz2s6l38795ygfr0000gq/T/error_handling-330a97.o -ledit -lm -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
  "_mpc_ast_delete", referenced from:
      _main in error_handling-330a97.o
  "_mpc_err_delete", referenced from:
      _main in error_handling-330a97.o
  "_mpc_err_print", referenced from:
      _main in error_handling-330a97.o
  "_mpc_new", referenced from:
      _main in error_handling-330a97.o
  "_mpc_parse", referenced from:
      _main in error_handling-330a97.o
  "_mpca_lang", referenced from:
      _main in error_handling-330a97.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
orangeduck commented 9 years ago

Hey,

I think you just need to include mpc.c in your build command:

cc -std=c99 -Wall mpc.c error_handling.c -ledit -lm -v -o error_handling

Thanks,

Dan

youfoundron commented 9 years ago

Ah jeez, my stupid mistake. Thanks for pointing that out!

orangeduck commented 9 years ago

No problem. Enjoy the rest of the book!