Resolved #26, shared libs work on linux

This commit is contained in:
2022-10-02 04:09:27 +11:00
parent 50cc5ca270
commit 467cd8d978
3 changed files with 4 additions and 4 deletions

View File

@@ -19,9 +19,9 @@ Special thanks to http://craftinginterpreters.com/ for their fantastic book that
## Building
For Windows and MacOS, simply run `make` in the root directory.
For Windows, Linux and MacOS, simply run `make` in the root directory.
For Linux, run `make repl-static` in the root directory (see [this issue for details](https://github.com/Ratstail91/Toy/issues/26)).
Note: For Linux, you may need to `cd` into the `out` directory before running.
Note: MacOS is not officially supported (no machines for testing), but we'll do our best!

View File

@@ -15,7 +15,7 @@ ifeq ($(shell uname),Darwin)
cp $(PWD)/$(TOY_OUTDIR)/lib$(OUTNAME).dylib /usr/local/lib/
$(CC) -DTOY_IMPORT $(CFLAGS) -o $(OUT) $(OBJ) $(LIBS)
else
$(CC) -DTOY_IMPORT $(CFLAGS) -o $(OUT) $(OBJ) -L$(realpath $(shell pwd)/../$(TOY_OUTDIR)) $(LIBS)
$(CC) -DTOY_IMPORT $(CFLAGS) -o $(OUT) $(OBJ) -Wl,-rpath,. -L$(realpath $(shell pwd)/../$(TOY_OUTDIR)) $(LIBS)
endif
$(OBJ): | $(ODIR)

View File

@@ -16,7 +16,7 @@ ifeq ($(findstring CYGWIN, $(shell uname)),CYGWIN)
else ifeq ($(shell uname),Linux)
#I can't get this working as a shared lib
LIBLINE=-Wl,--out-implib=../$(TOY_OUTDIR)/lib$(OUTNAME).a -Wl,--whole-archive $(OBJ) -Wl,--no-whole-archive
OUT=../$(TOY_OUTDIR)/$(OUTNAME)
OUT=../$(TOY_OUTDIR)/lib$(OUTNAME).so
CFLAGS += -fPIC
else ifeq ($(OS),Windows_NT)
LIBLINE =-Wl,--out-implib=../$(TOY_OUTDIR)/lib$(OUTNAME).dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive $(OBJ) -Wl,--no-whole-archive