tj / luna

luna programming language - a small, elegant VM implemented in C
2.46k stars 148 forks source link

Compilation errors ... #79

Closed eriksank closed 8 years ago

eriksank commented 8 years ago

This expression in the Makefile:

TEST_SRC = $(shell find {test,src}/*.c | sed '/luna/d')

leads to the following error:

find: `{test,src}/*.c': No such file or directory

I have had to replace it by:

TEST_SRC = $(shell find src/*.c test/*.c | sed '/luna/d')```

Another problem is that there is a missing linker flag. The linker fails to find the symbol pow, which is obviously defined in the standard math library:

gcc src/prettyprint.o src/errors.o src/state.o src/lexer.o src/object.o src/vm.o src/parser.o src/vec.o src/token.o src/luna.o src/hash.o src/codegen.o src/visitor.o src/ast.o src/string.o src/utils.o deps/linenoise/linenoise.o deps/linenoise/utf8.o  -o luna
src/lexer.o: In function `scan_number':
/home/ontop/luna/src/lexer.c:262: undefined reference to `pow'
/home/ontop/luna/src/lexer.c:264: undefined reference to `pow'
collect2: error: ld returned 1 exit status
Makefile:29: recipe for target 'luna' failed

It can be fixed by adding:

LDFLAGS = -lm

After these shenanigans, the vm compiles fine!

By the way, I don't have clang installed. So, I had to change the CC variable to gcc. Maybe it would make sense to fallback automatically on gcc when clang is nowhere to be found? Some logic inspecting $(which clang) could spare other people from the misery of having to fix that manually ...

jzbl commented 8 years ago

Had the same issue. The workaround helped. Using clang version 3.7.0 on Fedora23.