binding lua (newbie)

Discussion in 'C++' started by Roman Fordinal, Oct 13, 2004.

  1. please, what's wrong? :(

    #include <stdio.h>
    extern "C"
    {
    #include <lua.h>
    #include <lualib.h>
    }

    int main()
    {
    lua_State *L = lua_open(); /* opens Lua */
    // lua_baselibopen(L);
    // lua_iolibopen(L);
    lua_close(L);
    }


    g++ -Wall message.cc -o message
    /tmp/ccWx0Gia.o(.text+0x11): In function `main':
    : undefined reference to `lua_open'
    /tmp/ccWx0Gia.o(.text+0x1f): In function `main':
    : undefined reference to `lua_close'
    collect2: ld returned 1 exit status
     
    Roman Fordinal, Oct 13, 2004
    #1
    1. Advertising

  2. "Roman Fordinal" <> wrote in message
    news:ckj8a5$4h1$...
    > please, what's wrong? :(
    >
    > #include <stdio.h>
    > extern "C"
    > {
    > #include <lua.h>
    > #include <lualib.h>
    > }
    >
    > int main()
    > {
    > lua_State *L = lua_open(); /* opens Lua */
    > // lua_baselibopen(L);
    > // lua_iolibopen(L);
    > lua_close(L);
    > }
    >
    >
    > g++ -Wall message.cc -o message
    > /tmp/ccWx0Gia.o(.text+0x11): In function `main':
    > : undefined reference to `lua_open'
    > /tmp/ccWx0Gia.o(.text+0x1f): In function `main':
    > : undefined reference to `lua_close'
    > collect2: ld returned 1 exit status
    >


    You haven't included the relevant library in your linking stage. This isn't
    a C++ language issue, it's a 'how do I operate my compiler issue', -Llua
    might do the trick, but if not then consult your compiler documentation.

    john
     
    John Harrison, Oct 13, 2004
    #2
    1. Advertising

  3. John Harrison wrote:

    > You haven't included the relevant library in your linking stage. This
    > isn't a C++ language issue, it's a 'how do I operate my compiler issue',
    > -Llua might do the trick, but if not then consult your compiler
    > documentation.

    oh yes! thanx :)

    g++ -llua ... :)


    >
    > john
     
    Roman Fordinal, Oct 13, 2004
    #3
  4. Roman Fordinal wrote:
    > please, what's wrong? :(

    ...
    > g++ -Wall message.cc -o message
    > /tmp/ccWx0Gia.o(.text+0x11): In function `main':
    > : undefined reference to `lua_open'
    > /tmp/ccWx0Gia.o(.text+0x1f): In function `main':
    > : undefined reference to `lua_close'
    > collect2: ld returned 1 exit status

    Link with lua.
    g++ -Wall message.cc -o message -llua
    This is btw a lua question/gcc question not a C++ question
     
    =?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=, Oct 13, 2004
    #4
  5. Roman Fordinal

    Nick Guest

    "Roman Fordinal" <> wrote in message
    news:ckj8a5$4h1$...
    > please, what's wrong? :(
    >
    > #include <stdio.h>
    > extern "C"
    > {
    > #include <lua.h>
    > #include <lualib.h>
    > }
    >


    My advice would be to advance from "self-proclaimed newbie" to "got the hang
    of compiling C++ projects" before trying to tackle something as advanced as
    binding in a scripting language. I'm not trying to be insulting, I'm just
    saying it's a good idea to get the hang of the basic stuff or else things
    like this will be really difficult.

    You should also look at one of the many code wrappers that people have made
    to facilitate binding Lua to C/C++. Luabind is quite popular.
    http://lua-users.org/wiki/LuaAddons
     
    Nick, Oct 15, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Benson

    Lua, Lunatic and Python

    John Benson, Dec 13, 2003, in forum: Python
    Replies:
    0
    Views:
    322
    John Benson
    Dec 13, 2003
  2. Gustavo Niemeyer

    Re: Lua, Lunatic and Python

    Gustavo Niemeyer, Dec 13, 2003, in forum: Python
    Replies:
    28
    Views:
    886
    Stephen J. Bevan
    Dec 19, 2003
  3. John Benson
    Replies:
    4
    Views:
    350
    Frank Bechmann
    Jan 2, 2004
  4. John Benson
    Replies:
    4
    Views:
    728
    David M. Cooke
    Jan 9, 2004
  5. John Benson

    Lua versus C++ for embedded processor

    John Benson, Jan 14, 2004, in forum: Python
    Replies:
    5
    Views:
    566
    Cameron Laird
    Sep 14, 2004
Loading...

Share This Page