lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I have a lua script (dbtest.lua), which includes a "require" (require("pgsql")), which runs fine standalone (lua dbtest.lua), but when called from a C++ program, generates an error:

-- error loading module 'pgsql' from file '/usr/local/lib/lua/5.1/pgsql.so':
        /usr/local/lib/lua/5.1/pgsql.so: undefined symbol: lua_isuserdata

dbtest.cpp was compiled using:
g++ -o dbtest{,.cpp} -llua -ldl

I'm missing some little piece of information: what is that?

I'm running CentOS 5.3, Lua 5.1.4. The C++ program reads:

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

void report_errors(lua_State *L, int status)
{
  if ( status!=0) {
    std::cout << "-- " << lua_tostring(L, -1) << std::endl;
    lua_pop(L, 1);
  }
}

int main()
{
  lua_State *L = lua_open();
  luaL_openlibs(L);
  int s = luaL_loadfile(L, "dbtest.lua");
  if ( s == 0 ) {
    s = lua_pcall(L, 0, 0, 0);
  }
  report_errors(L, s);
  lua_close(L);
  return 0;
}

- Mark