From 704b8ad8108716e2c464015e9168678515b4e62c Mon Sep 17 00:00:00 2001 From: Greg Price Date: Sat, 28 Oct 2017 23:31:54 -0700 Subject: [PATCH] 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. --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 603a1dc7..cb184c20 100644 --- a/README.md +++ b/README.md @@ -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