lunarmodules / luasql

LuaSQL is a simple interface from Lua to a DBMS.
http://lunarmodules.github.io/luasql
535 stars 192 forks source link

luarocks install luasql-odbc Error !! #118

Open yabb-cyber opened 4 years ago

yabb-cyber commented 4 years ago

Luarocks install luasql-odbc error compile. gcc -O2 -fPIC -I/usr/include/lua5.2 -c src/luasql.c -o src/luasql.o -I/usr/include gcc -O2 -fPIC -I/usr/include/lua5.2 -c src/ls_odbc.c -o src/ls_odbc.o -I/usr/include src/ls_odbc.c:39:2: error: unknown type name ‘SQLHENV’ SQLHENV henv; / environment handle / ^~~ src/ls_odbc.c:47:2: error: unknown type name ‘SQLHDBC’ SQLHDBC hdbc; / database connection handle / ^~~ src/ls_odbc.c:56:2: error: unknown type name ‘SQLHSTMT’ SQLHSTMT hstmt; / statement handle / ^~~~ src/ls_odbc.c:117:38: error: unknown type name ‘SQLSMALLINT’ static int fail(lua_State L, const SQLSMALLINT type, const SQLHANDLE handle) { ^~~ src/ls_odbc.c:117:62: error: unknown type name ‘SQLHANDLE’ static int fail(lua_State L, const SQLSMALLINT type, const SQLHANDLE handle) { ^~~~~ src/ls_odbc.c: In function ‘fail’:

tyree731 commented 4 years ago

Looks like a patch could be as simple as:

diff --git a/rockspec/luasql-odbc-cvs-1.rockspec b/rockspec/luasql-odbc-cvs-1.rockspec
index 99a45fe..37e599d 100644
--- a/rockspec/luasql-odbc-cvs-1.rockspec
+++ b/rockspec/luasql-odbc-cvs-1.rockspec
@@ -23,8 +23,8 @@ external_dependencies = {
 }
 build = {
    type = "make",
+   build_target = "odbc",
    variables = {
-      T="odbc",
       LIB_OPTION = "$(LIBFLAG) -L$(ODBC_LIBDIR) -lodbc",
       CFLAGS = "$(CFLAGS) -I$(LUA_INCDIR) -I$(ODBC_INCDIR) -DUNIXODBC"
    },

Does this seem reasonable?

tomasguisasola commented 4 years ago

It seems the ODBC driver is outdated. I checked with both unixodbc and libiodbc2-dev Ubuntu packages and they provide different sql.h files, any of these are compatible with LuaSQL ODBC driver...

tyree731 commented 4 years ago

In our case we're using RHEL7, which presumably has fairly old odbc drivers, so I wouldn't be surprised. That said, if the proposed patch makes lua-odbc work with old and new versions of odbc libraries, isn't that a good thing to merge?