README: Make the examples work despite variation in out/*/ structure.

Fixes #102.  While on macOS the `libcompiler.a` and `libruntime.a`
files apparently get output directly into `out/Release/` by the build,
on Linux they seem to go into a subdirectory `out/Release/obj.target/`.

This causes someone who tries to follow the instructions to get an
error like
```
/usr/bin/ld: cannot find -lcompiler
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

That looks like the setup is broken somehow, and for someone who
hasn't spent much time fixing up Unix linker errors, it doesn't give a
lot of clues as to how to fix it.

Instead, have the recommended command find the actual library file
directly, and pass that to the linker.  (Alternatively we could have
passed the containing directory to `-L`; this is a little shorter, and
of course neither version is what you'd want in an industrial-strength
build recipe.)

This isn't the world's most elegant solution, obviously -- it'd be
better (at least as far as this part is concerned) to have the layout
be the same on different platforms.  But doing that sounds likely to
require significant messing around with build scripts, so this at
least makes the instructions work reliably.
This commit is contained in:
Greg Price 2017-10-28 23:31:54 -07:00
parent 6bfe95fc95
commit 704b8ad810

View file

@ -136,9 +136,8 @@ To create the parser, compile this file like this:
```sh
clang++ -std=c++11 \
-I tree-sitter/include \
-L tree-sitter/out/Release \
arithmetic_grammar.cc \
-l compiler \
"$(find tree-sitter/out/Release -name libcompiler.a)" \
-o arithmetic_grammar
```
@ -208,9 +207,8 @@ To demo this parser's capabilities, compile this program like this:
```sh
clang \
-I tree-sitter/include \
-L tree-sitter/out/Release \
test_parser.c arithmetic_parser.c \
-l runtime \
"$(find tree-sitter/out/Release -name libruntime.a)" \
-o test_parser
./test_parser