Jump to content

Library linking problems - lualib

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
OScoder

OScoder

    Newbie

  • Members
  • Pip
  • 2 posts
Hi there!
I'm experimenting with the LUA API atm, but for some reason it doesn't seem to be linking properly. I'm on linux (slackware), and I've compiled and installed the most recent version of lua.

Here's the output:

gcc -o voipscript -llua main.o resources.o siplib.o

main.o: In function `main':

main.c:(.text+0x83): undefined reference to `luaL_newstate'

main.c:(.text+0x9d): undefined reference to `luaL_loadfile'

collect2: ld returned 1 exit status

make: *** [all] Error 1


As you can see, I've linked to lua with the '-llua' switch. Can anyone tell me why it doesn't link properly? (at least I'm assuming that's the problem)

Thanks in advance,
OScoder

#2
ZekeDragon

ZekeDragon

    Writes binary right handed and hex left handed

  • Moderators
  • 2,103 posts
GCC don't work that way. You set the object files before the "-o" flag, as well as the library, which goes after the object files, like so:
gcc main.o resources.o siplib.o -llua -o voipscript
Basically, it goes "gcc <.o files> <-l libs> -o <program name>", though it's easier to just do it all from one command line instead of worrying about linking .o files.
gcc -Wall main.c resources.c siplib.c -llua -o voipscript
That should all work!
Wow I changed my sig!

#3
OScoder

OScoder

    Newbie

  • Members
  • Pip
  • 2 posts
That's got it :-). Thankyou!