Thread: Wierd undefined reference

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,735

    Wierd undefined reference

    Trying to implement the first gasp class for lua and it keeps spitting out this one undefined reference, I've tried looking it up but I keep getting more general results related to just adding the -llua switch or adding it's directory, gotta go help a neighbor now so hoping to get a possible solution posted while I'm doing that
    Code:
    make --no-print-directory rebuild
    Already up to date.
    Already up to date.
    Already up to date.
    Already up to date.
    rm -f *.elf
    rm -f *.o
    rm -f cloned/lua/*.o
    rm -f cloned/moongl/src/*.o
    rm -f cloned/moonglfw/src/*.o
    rm -f cloned/moonnuklear/src/*.o
    rm -f *.so
    rm -f cloned/lua/*.so
    rm -f cloned/moongl/src/*.so
    rm -f cloned/moonglfw/src/*.so
    rm -f cloned/moonnuklear/src/*.so
    ...
    cp cloned/moongl/src/moongl.so moongl.so
    cp cloned/moonglfw/src/moonglfw.so moonglfw.so
    cp cloned/moonnuklear/src/moonnuklear.so moonnuklear.so
    cc -fpic -Wall -Wextra -Wpedantic -std=c99 -D _GNU_SOURCE -D LINUX -D LUA_USE_LINUX -D LUA_USE_READLINE -D LUAVER=5.3 -I cloned/lua -o gasp.c.o -c gasp.c
    gasp.c: In function ‘main’:
    gasp.c:11:9: warning: variable ‘size’ set but not used [-Wunused-but-set-variable]
       11 |  size_t size = 0, leng = BUFSIZ;
          |         ^~~~
    cc -fpic -Wall -Wextra -Wpedantic -std=c99 -D _GNU_SOURCE -D LINUX -D LUA_USE_LINUX -D LUA_USE_READLINE -D LUAVER=5.3 -I cloned/lua -o space.c.o -c space.c
    cc -fpic -Wall -Wextra -Wpedantic -std=c99 -D _GNU_SOURCE -D LINUX -D LUA_USE_LINUX -D LUA_USE_READLINE -D LUAVER=5.3 -I cloned/lua -o nodes.c.o -c nodes.c
    cc -fpic -Wall -Wextra -Wpedantic -std=c99 -D _GNU_SOURCE -D LINUX -D LUA_USE_LINUX -D LUA_USE_READLINE -D LUAVER=5.3 -I cloned/lua -o proc.c.o -c proc.c
    cc -fpic -Wall -Wextra -Wpedantic -std=c99 -D _GNU_SOURCE -D LINUX -D LUA_USE_LINUX -D LUA_USE_READLINE -D LUAVER=5.3 -I cloned/lua -o arguments.c.o -c arguments.c
    cc -fpic -o gasp.elf gasp.c.o space.c.o nodes.c.o proc.c.o arguments.c.o -L"." -Wl,-rpath,"." -ldl -lm -lpthread -llua
    /usr/bin/ld: proc.c.o: in function `lua_proc_load_glance':
    proc.c:(.text+0x5408): undefined reference to `lua_newuserdatauv'
    collect2: error: ld returned 1 exit status
    make: *** [makefile:132: gasp.elf] Error 1
    Compilation failed.

  2. #2
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,735
    I resolved it by declaring the use of the cloned lua repository before including the library, currently I have that declaration in both the compilation stage and the linker stage, not inclined to change since that would probably break it again

    Edit: Here's a snippet from the end of my output
    Code:
    cc -fpic -L "cloned/lua" -I cloned/lua -Wall -Wextra -Wpedantic -std=c99 -D _GNU_SOURCE -D LINUX -D LUA_USE_LINUX -D LUA_USE_READLINE -D LUAVER=5.3 -o deep_gasp.c.o -c deep_gasp.c -llua -ldl -lm -lpthread
    cc -fpic -L "cloned/lua" -o deep-gasp.elf deep_gasp.c.o space.c.o nodes.c.o proc.c.o arguments.c.o -llua -ldl -lm -lpthread
    Compilation finished successfully.
    For anyone wandering about the deep-gasp.elf part, that's the executable launched under pkexec by gasp.elf, only way I could get round the lack of permissions was to just launch under pkexec and let the user authorise, the problem with that was lack of environment variables so I copied only what was needed into the arguments, to give the user an idea of what deep-gasp.elf and the lua it runs can access I print the full command before executing it
    Last edited by awsdert; 02-11-2020 at 11:36 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to C; Undefined reference
    By neduag in forum C Programming
    Replies: 3
    Last Post: 06-29-2015, 02:52 PM
  2. Dev C++: undefined reference to...
    By mahece28 in forum C Programming
    Replies: 3
    Last Post: 04-09-2015, 09:12 PM
  3. undefined reference
    By ivo93 in forum C++ Programming
    Replies: 2
    Last Post: 04-20-2013, 05:47 AM
  4. Undefined reference ?
    By Holymanus in forum C Programming
    Replies: 6
    Last Post: 01-07-2011, 09:15 AM
  5. undefined reference to
    By diego in forum C++ Programming
    Replies: 4
    Last Post: 05-18-2010, 03:06 PM

Tags for this Thread