title: problems embedding lua in c++
body: <p>I am attempting to embed lua code in C++, and I'm getting a strange compiler error.  Here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  extern "C" {
  #include &lt;lua.h&gt;
  #include &lt;lauxlib.h&gt;
  #include &lt;lualib.h&gt;
  }
  
  int main() {
      lua_State *luaVM = luaL_newstate();
      if (luaVM == NULL) {
          printf("Error initializing lua!\n");
          return -1;
      }
  
      luaL_openlibs(luaVM);
  
      luaL_dofile(luaVM, "test.lua");
  
      lua_close(luaVM);
  
      return 0;
  }
  </code></pre>
  
  <p>compiled with:</p>
  
  <pre><code>g++ -Wall -o embed -llua embed.cpp
  </code></pre>
  
  <p>and the error is:</p>
  
  <pre><code>g++ -Wall -o embed -llua embed.cpp
  /tmp/ccMGuzal.o: In function `main':
  embed.cpp:(.text+0x47): undefined reference to `luaL_loadfilex'
  embed.cpp:(.text+0x72): undefined reference to `lua_pcallk'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>I am not calling <code>luaL_loadfilex</code> or <code>lua_pcallk</code> from my code, which lends itself to the assumption that the problem is not in my code, but in lua itself.  does anyone have any ideas here?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Here is my version info:</p>
  
  <pre><code>$ lua -v
  Lua 5.2.0  Copyright (C) 1994-2011 Lua.org, PUC-Rio
  </code></pre>