lunarmodules / luasql

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

Issue installation mac os 10.14 #131

Closed lodumont closed 2 years ago

lodumont commented 2 years ago

I'm facing an issue installing luasql-odbc on mac os 10.14. I have lua 5.4 and luarocks, both installed with homebrew.

When I try : luarocks install luasql-odbc I get:

Installing https://luarocks.org/luasql-odbc-2.6.0-1.rockspec
Cloning into 'luasql'...
remote: Enumerating objects: 149, done.
remote: Counting objects: 100% (149/149), done.
remote: Compressing objects: 100% (99/99), done.
remote: Total 149 (delta 72), reused 72 (delta 36), pack-reused 0
Receiving objects: 100% (149/149), 104.13 KiB | 6.94 MiB/s, done.
Resolving deltas: 100% (72/72), done.
Note: checking out '22d4a911f35cf851af9db71124e3998d96fb3fa1'.

luasql-odbc 2.6.0-1 depends on lua >= 5.1 (5.4-1 provided by VM)
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/usr/local/opt/lua/include/lua5.4 -c src/luasql.c -o src/luasql.o -I/usr/local/include
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/usr/local/opt/lua/include/lua5.4 -c src/ls_odbc.c -o src/ls_odbc.o -I/usr/local/include
src/ls_odbc.c:37:2: error: unknown type name 'SQLPOINTER'
        SQLPOINTER buf;
        ^
src/ls_odbc.c:38:2: error: unknown type name 'SQLINTEGER'
        SQLINTEGER len;
        ^
src/ls_odbc.c:39:2: error: unknown type name 'SQLINTEGER'
        SQLINTEGER type;
        ^
src/ls_odbc.c:51:2: error: unknown type name 'SQLHENV'
        SQLHENV       henv;               /* environment handle */
        ^
src/ls_odbc.c:58:2: error: unknown type name 'SQLHDBC'
        SQLHDBC       hdbc;               /* database connection handle */
        ^
src/ls_odbc.c:66:2: error: unknown type name 'SQLHSTMT'
        SQLHSTMT      hstmt;              /* statement handle */
        ^
src/ls_odbc.c:67:2: error: unknown type name 'SQLSMALLINT'
        SQLSMALLINT   numparams;          /* number of input parameters */
        ^
src/ls_odbc.c:85:18: error: unknown type name 'SQLRETURN'
static int error(SQLRETURN a)
                 ^
src/ls_odbc.c:87:15: error: use of undeclared identifier 'SQL_SUCCESS'
        return (a != SQL_SUCCESS) && (a != SQL_SUCCESS_WITH_INFO) && (a ...
                     ^
src/ls_odbc.c:87:37: error: use of undeclared identifier 'SQL_SUCCESS_WITH_INFO'
        return (a != SQL_SUCCESS) && (a != SQL_SUCCESS_WITH_INFO) && (a ...
                                           ^
src/ls_odbc.c:87:69: error: use of undeclared identifier 'SQL_NO_DATA'
  ...(a != SQL_SUCCESS) && (a != SQL_SUCCESS_WITH_INFO) && (a != SQL_NO_DATA);
                                                                 ^
src/ls_odbc.c:195:38: error: unknown type name 'SQLSMALLINT'
static int fail(lua_State *L,  const SQLSMALLINT type, const SQLHANDLE handle) {
                                     ^
src/ls_odbc.c:195:62: error: unknown type name 'SQLHANDLE'
static int fail(lua_State *L,  const SQLSMALLINT type, const SQLHANDLE handle) {
                                                             ^
src/ls_odbc.c:196:5: error: use of undeclared identifier 'SQLCHAR'
    SQLCHAR State[6];
    ^
src/ls_odbc.c:197:5: error: use of undeclared identifier 'SQLINTEGER'
    SQLINTEGER NativeError;
    ^
src/ls_odbc.c:198:5: error: use of undeclared identifier 'SQLSMALLINT'
    SQLSMALLINT MsgSize, i;
    ^
src/ls_odbc.c:199:5: error: use of undeclared identifier 'SQLRETURN'
    SQLRETURN ret;
    ^
src/ls_odbc.c:200:5: error: use of undeclared identifier 'SQLCHAR'
    SQLCHAR Msg[SQL_MAX_MESSAGE_LENGTH];
    ^
src/ls_odbc.c:205:5: error: use of undeclared identifier 'i'
    i = 1;
    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

Error: Build error: Failed compiling object src/ls_odbc.o

Any idea how I could make this work? Thank you!

tomasguisasola commented 2 years ago

Hi lodumont

LuaSQL is a peculiar piece of code, since it creates a one-direction bridge between two other software: from Lua to the DBMS. Thus, you have to provide the header files from both software. It seems you already have the Lua side at /usr/local/opt/lua/include/lua5.4. Now you have to provide the DBMS side. Try to find out one of the header files in ls_odbc.c:

if defined(_WIN32)

include

include

elif defined(INFORMIX)

include "infxcli.h"

elif defined(UNIXODBC)

include "sql.h"

include "sqltypes.h"

include "sqlext.h"

endif

This depends on the ODBC interface provided by database you have installed. Those file might define the names showed in the error messages, such as SQLPOINTER and SQLINTEGER.

Hope this helps!

Regards, Tomás

Em ter., 12 de out. de 2021 às 13:53, lodumont @.***> escreveu:

I'm facing an issue installing luasql-odbc on mac os 10.14. I have lua 5.4 and luarocks, both installed with homebrew.

When I try : luarocks install luasql-odbc I get:

`Installing https://luarocks.org/luasql-odbc-2.6.0-1.rockspec Cloning into 'luasql'... remote: Enumerating objects: 149, done. remote: Counting objects: 100% (149/149), done. remote: Compressing objects: 100% (99/99), done. remote: Total 149 (delta 72), reused 72 (delta 36), pack-reused 0 Receiving objects: 100% (149/149), 104.13 KiB | 6.94 MiB/s, done. Resolving deltas: 100% (72/72), done. Note: checking out '22d4a911f35cf851af9db71124e3998d96fb3fa1'.

luasql-odbc 2.6.0-1 depends on lua >= 5.1 (5.4-1 provided by VM) env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/usr/local/opt/lua/include/lua5.4 -c src/luasql.c -o src/luasql.o -I/usr/local/include env MACOSX_DEPLOYMENT_TARGET=10.8 gcc -O2 -fPIC -I/usr/local/opt/lua/include/lua5.4 -c src/ls_odbc.c -o src/ls_odbc.o -I/usr/local/include src/ls_odbc.c:37:2: error: unknown type name 'SQLPOINTER' SQLPOINTER buf; ^ src/ls_odbc.c:38:2: error: unknown type name 'SQLINTEGER' SQLINTEGER len; ^ src/ls_odbc.c:39:2: error: unknown type name 'SQLINTEGER' SQLINTEGER type; ^ src/ls_odbc.c:51:2: error: unknown type name 'SQLHENV' SQLHENV henv; /* environment handle

/ ^ src/ls_odbc.c:58:2: error: unknown type name 'SQLHDBC' SQLHDBC hdbc; / database connection handle

/ ^ src/ls_odbc.c:66:2: error: unknown type name 'SQLHSTMT' SQLHSTMT hstmt; / statement handle

/ ^ src/ls_odbc.c:67:2: error: unknown type name 'SQLSMALLINT' SQLSMALLINT numparams; / number of input parameters / ^ src/ls_odbc.c:85:18: error: unknown type name 'SQLRETURN' static int error(SQLRETURN a) ^ src/ls_odbc.c:87:15: error: use of undeclared identifier 'SQL_SUCCESS' return (a != SQL_SUCCESS) && (a != SQL_SUCCESS_WITH_INFO) && (a ... ^ src/ls_odbc.c:87:37: error: use of undeclared identifier 'SQL_SUCCESS_WITH_INFO' return (a != SQL_SUCCESS) && (a != SQL_SUCCESS_WITH_INFO) && (a ... ^ src/ls_odbc.c:87:69: error: use of undeclared identifier 'SQL_NO_DATA' ...(a != SQL_SUCCESS) && (a != SQL_SUCCESS_WITH_INFO) && (a != SQL_NO_DATA); ^ src/ls_odbc.c:195:38: error: unknown type name 'SQLSMALLINT' static int fail(lua_State L, const SQLSMALLINT type, const SQLHANDLE handle) { ^ src/ls_odbc.c:195:62: error: unknown type name 'SQLHANDLE' static int fail(lua_State *L, const SQLSMALLINT type, const SQLHANDLE handle) { ^ src/ls_odbc.c:196:5: error: use of undeclared identifier 'SQLCHAR' SQLCHAR State[6]; ^ src/ls_odbc.c:197:5: error: use of undeclared identifier 'SQLINTEGER' SQLINTEGER NativeError; ^ src/ls_odbc.c:198:5: error: use of undeclared identifier 'SQLSMALLINT' SQLSMALLINT MsgSize, i; ^ src/ls_odbc.c:199:5: error: use of undeclared identifier 'SQLRETURN' SQLRETURN ret; ^ src/ls_odbc.c:200:5: error: use of undeclared identifier 'SQLCHAR' SQLCHAR Msg[SQL_MAX_MESSAGE_LENGTH]; ^ src/ls_odbc.c:205:5: error: use of undeclared identifier 'i' i = 1; ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated.

Error: Build error: Failed compiling object src/ls_odbc.o`

Any idea how I could make this work? Thank you!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/keplerproject/luasql/issues/131, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABAB3JO5O3U2SDBKHKUES3UGRRXJANCNFSM5F3BEU2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

laigor commented 2 years ago

Try https://github.com/keplerproject/luasql/issues/129#issuecomment-927314549

tomasguisasola commented 2 years ago

Hi laigor

Adding CFLAGS="-DUNIXODBC" to LuaRocks command line solves the problem?

If it does, should we close those issues here on GitHub?

Regards, Tomás

lodumont commented 2 years ago

Thanks a lot for your advice, I solved my issue by adding CFLAGS="-DUNIXODBC" to the luarocks command. Unixodbc was installed but apparently not automatically detected.

laigor commented 2 years ago

I think it's too early to close this task. UNXIODBC should be detected automatically for linux and mac. Otherwise, it turns out that everyone, when installing luasql-odbc on linux or mac, will have to figure out why not to install ... At least it is necessary to write in the documentation how to do this so that there are no compilation errors.