
Originally Posted by
Hodor
It loads libraries like the docs say in my own code. What do you mean by "lua is not loading libraries as the docs describe"?
I mean when it should be loading the moon libraries it just shuts down execution and passes back to gasp like nothing happend, since gasp shuts down after calling the file I've not got any information on why, I least expected lua to call the error handler if it couldn't load it but not even that gets called. Because lua didn't do as described by the docs I thought maybe it's because I'm using the system version of lua and not compiling lua myself so I modified my makefile a bit (and learned a better way of cloning & updating github code in the process) and got as far as this:
Code:
make --no-print-directory
make: Circular moonnuklear.so.o <- moonnuklear.so dependency dropped.
make: Circular moonglfw.so.o <- moonglfw.so dependency dropped.
clang -ldl -lm -L'.' -lgasp-lua -o gasp.elf gasp.c.o
make: Circular moongl.so.o <- moongl.so dependency dropped.
clang -ggdb -D _DEBUG -shared -fPIC -fpic -ldl -lm -L'.' -o libgasp-lua-d.so cloned/lua/lopcodes.c-d.o cloned/lua/ltm.c-d.o cloned/lua/loslib.c-d.o cloned/lua/lctype.c-d.o cloned/lua/lstate.c-d.o cloned/lua/ltablib.c-d.o cloned/lua/ltests.c-d.o cloned/lua/lzio.c-d.o cloned/lua/lparser.c-d.o cloned/lua/llex.c-d.o cloned/lua/ldblib.c-d.o cloned/lua/lvm.c-d.o cloned/lua/lcode.c-d.o cloned/lua/lcorolib.c-d.o cloned/lua/ldump.c-d.o cloned/lua/liolib.c-d.o cloned/lua/ldebug.c-d.o cloned/lua/loadlib.c-d.o cloned/lua/linit.c-d.o cloned/lua/lmathlib.c-d.o cloned/lua/lbaselib.c-d.o cloned/lua/lstring.c-d.o cloned/lua/lutf8lib.c-d.o cloned/lua/lmem.c-d.o cloned/lua/ldo.c-d.o cloned/lua/lauxlib.c-d.o cloned/lua/lobject.c-d.o cloned/lua/lstrlib.c-d.o cloned/lua/lundump.c-d.o cloned/lua/ltable.c-d.o cloned/lua/lapi.c-d.o cloned/lua/lgc.c-d.o cloned/lua/lfunc.c-d.o
clang -ggdb -D _DEBUG -ldl -lm -L'.' -llibgasp-lua-d.so -o gasp-d.elf gasp.c-d.o
/usr/bin/ld: cannot find -llibgasp-lua-d.so
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [makefile:78: gasp-d.elf] Error 1
Compilation failed.
Struggling to see why it keeps producing these library object errors when they are never even referred to at any point in the makefile, the inability to find the library I fixed by just correcting my usage of -l (I forgot about it when I moved the variable across)
Here's a dump of my makefile, if anyone could help me fix that issue as well then that would be great:
Code:
USE_MINGW:=
CC=clang
HAS_DOS:=$(if $(COMSPEC),1,)
IS_WINDOWS:=$(if $(ProgramFiles),1,)
IS_MSDOS:=$(if $(IS_WINDOWS),,$(HAS_DOS))
IS_WIN64:=$(if ${ProgramFiles(x86)},1,)
IS_WIN32:=$(if $(IS_WIN64),,$(IS_WINDOWS))
IS_MACOS:=
IS_LINUX:=$(if $(IS_WINDOWS),,1)
mkdir=$(if $(wildcard $1),,$(shell mkdir $1))
clone=$(if $(wildcard $1),,$(shell cd $2 && git clone https://github.com/$3))
update=$(shell cd $1 && git remote update)
_fetch=$(shell cd $1 && git fetch $2)
fetch=$(if $(call _fetch,$1,--dry-run),$(call _fetch,$1),)
#gasp stands for Gaming Assistive tech for Solo Play
#Wanted a more fun name than just plain cheat and since
#there are people who need to cheat to be able to play
#(for example the elderly or physically challanged)
#I thought to tie in the name to such audience, let's
#see gaming companies find an excuse for exlcuding that
#audience when they eventually find a way to block this :)
gasp_sources=gasp.c
gasp_objects=$(gasp_sources:%=%.o)
gasp_dbgobjs=$(gasp_sources:%=%-d.o)
gasp_exe=gasp.elf
gasp_dbg_exe=gasp-d.elf
all: $(gasp_exe) $(gasp_dbg_exe)
lua_dir=cloned/lua
moongl_dir=cloned/moongl
moonglfw_dir=cloned/moonglfw
moonnuklear_dir=cloned/moonnuklear
$(call mkdir,cloned)
$(call clone,$(lua_dir),cloned,lua/lua)
$(call clone,$(moongl_dir),cloned,stetre/moongl)
$(call clone,$(moonglfw_dir),cloned,stetre/moonglfw)
$(call clone,$(moonnuklear_dir),cloned,stetre/moonnuklear)
$(call fetch,$(lua_dir))
$(call fetch,$(moongl_dir))
$(call fetch,$(moonglfw_dir))
$(call fetch,$(moonnuklear_dir))
lua_src_dir=$(lua_dir)
lua_sources:=$(filter-out $(lua_src_dir)/lua.c $(lua_src_dir)/onelua.c,$(wildcard $(lua_src_dir)/*.c))
lua_objects:=$(lua_sources:%=%.o)
lua_dbgobjs:=$(lua_sources:%=%-d.o)
lua_dll=libgasp-lua.so
lua_dbg=libgasp-lua-d.so
moongl_dll=moongl.so
moongl_src_dir:=$(moongl_dir)/src
moonglfw_dll=moonglfw.so
moonglfw_src_dir:=$(moonglfw_dir)/src
moonnuklear_dll=moonnuklear.so
moonnuklear_src_dir:=$(moonnuklear_dir)/src
bin_flags=-ldl -lm -L'.'
lib_flags=-shared -fPIC -fpic $(bin_flags)
dlls:=moonnuklear.so moonglfw.so moongl.so
inc_flags=-I $(lua_dir) -I $(moonnuklear_dir) -I $(moonglfw_dir) -I $(moongl_dir)
src_flags=-Wall -std=c99 -DLUA_USE_LINUX -DLUA_USE_READLINE
dbg_flags=-ggdb -D _DEBUG
gasp: $(gasp_exe)
./$(gasp_exe)
$(gasp_exe): $(gasp_objects) $(lua_dll) $(dlls) force
$(CC) $(bin_flags) -lgasp-lua -o $@ $(gasp_objects)
debug: $(gasp_dbg_exe)
gede --args ./$(gasp_dbg_exe)
$(gasp_dbg_exe): $(gasp_dbgobjs) $(lua_dbg) $(dlls) force
$(CC) $(dbg_flags) $(bin_flags) -lgasp-lua-d -o $@ $(gasp_dbgobjs)
$(lua_dll): $(lua_objects)
$(CC) $(lib_flags) -o $@ $^
$(lua_dbg): $(lua_dbgobjs)
$(CC) $(dbg_flags) $(lib_flags) -o $@ $^
%.o: %
$(CC) $(inc_flags) $(src_flags) -o $@ -c $<
%-d.o: %
$(CC) $(dbg_flags) $(inc_flags) $(src_flags) -o $@ -c $<
force: ;
.PHONY: all gasp debug makefile