ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
188 stars 151 forks source link

Installing driver fails with with "../src/odbc.h:142:23: error: cast from 'std::nullptr_t' to 'SQLHENV' {aka 'int'}..." #894

Closed janvda closed 1 year ago

janvda commented 1 year ago

Running in alpine docker container on my macbook

bash-5.1$ uname -a
Linux f6727d6f5e15 5.10.93-0-virt #1-Alpine SMP Thu, 27 Jan 2022 09:34:38 +0000 x86_64 Linux

Note that I have installed following packages:

RUN apk add alpine-sdk libc6-compat linux-pam libxml2 python3 py3-pip sudo loksh
bash-5.1$ uname
Linux
bash-5.1$   uname -m
x86_64

Only PATH is set:

f6727d6f5e15:~# echo $IBM_DB_HOME

f6727d6f5e15:~# echo $PATH
/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
f6727d6f5e15:~# echo $LIB

f6727d6f5e15:~# echo $LD_LIBRARY_PATH

f6727d6f5e15:~# echo $DYLD_LIBRARY_PATH

f6727d6f5e15:~# 
f6727d6f5e15:~# whoami
root
f6727d6f5e15:~# npm install ibm_db
npm ERR! code 1
npm ERR! path /root/node_modules/ibm_db
npm ERR! command failed
npm ERR! command sh -c node installer/driverInstall.js
npm ERR! platform = linux, arch = x64, node.js version = v16.16.0
npm ERR! make version =GNU Make 4.3
npm ERR! 
npm ERR! ****************************************
npm ERR! You are downloading a package which includes the Node.js module for IBM DB2/Informix.  The module is licensed under the Apache License 2.0. The package also includes IBM ODBC and CLI Driver from IBM, which is automatically downloaded as the node module is installed on your system/device. The license agreement to the IBM ODBC and CLI Driver is available in /root/node_modules/ibm_db/installer/clidriver. Check for additional dependencies, which may come with their own license agreement(s). Your use of the components of the package and dependencies constitutes your acceptance of their respective license agreements. If you do not accept the terms of any license agreement(s), then delete the relevant component(s) from your device.
npm ERR! ****************************************
npm ERR! 
npm ERR! Downloading DB2 ODBC CLI Driver from https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz ...
npm ERR! 
100.00% | 25012651 bytes downloaded out of 25012651 bytes.
npm ERR! 
npm ERR! Downloading and extraction of DB2 ODBC CLI Driver completed successfully.
npm ERR! 
npm ERR! make: Entering directory '/root/node_modules/ibm_db/build'
npm ERR!   CXX(target) Release/obj.target/odbc_bindings/src/odbc.o
npm ERR! make: Leaving directory '/root/node_modules/ibm_db/build'
npm ERR! 
npm ERR! Error: Command failed: node-gyp configure build  --IS_DOWNLOADED=true --IBM_DB_HOME="$IBM_DB_HOME"
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@16.16.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.10.5 found at "/usr/bin/python3"
npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v16.16.0/node-v16.16.0-headers.tar.gz
npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v16.16.0/node-v16.16.0-headers.tar.gz
npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v16.16.0/SHASUMS256.txt
npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v16.16.0/SHASUMS256.txt
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/node_modules/ibm_db/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.cache/node-gyp/16.16.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/16.16.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/16.16.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/root/node_modules/ibm_db',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/odbc.cpp:29:
npm ERR! ../src/odbc.h: In constructor 'ODBC::ODBC()':
npm ERR! ../src/odbc.h:142:23: error: cast from 'std::nullptr_t' to 'SQLHENV' {aka 'int'} loses precision [-fpermissive]
npm ERR!   142 |     ODBC() { m_hEnv = (SQLHENV)NULL; }
npm ERR!       |                       ^
npm ERR! ../src/odbc.cpp: In member function 'void ODBC::Free()':
npm ERR! ../src/odbc.cpp:110:14: error: cast from 'std::nullptr_t' to 'SQLHENV' {aka 'int'} loses precision [-fpermissive]
npm ERR!   110 |     m_hEnv = (SQLHENV)NULL;
npm ERR!       |              ^
npm ERR! ../src/odbc.cpp: In static member function 'static Nan::NAN_METHOD_RETURN_TYPE ODBC::New(Nan::NAN_METHOD_ARGS_TYPE)':
npm ERR! ../src/odbc.cpp:122:17: error: cast from 'std::nullptr_t' to 'SQLHENV' {aka 'int'} loses precision [-fpermissive]
npm ERR!   122 |   dbo->m_hEnv = (SQLHENV)NULL;
npm ERR!       |                 ^
npm ERR! ../src/odbc.cpp: In static member function 'static void ODBC::UV_AfterCreateConnection(uv_work_t*, int)':
npm ERR! ../src/odbc.cpp:216:19: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
npm ERR!   216 |     data->cb->Call(1, info);
npm ERR!       |     ~~~~~~~~~~~~~~^~~~~~~~~
npm ERR! In file included from ../src/odbc.h:23,
npm ERR!                  from ../src/odbc.cpp:29:
npm ERR! ../../nan/nan.h:1746:3: note: declared here
npm ERR!  1746 |   Call(int argc, v8::Local<v8::Value> argv[]) const {
npm ERR!       |   ^~~~
npm ERR! ../src/odbc.cpp:228:19: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
npm ERR!   228 |     data->cb->Call(2, info);
npm ERR!       |     ~~~~~~~~~~~~~~^~~~~~~~~
npm ERR! In file included from ../src/odbc.h:23,
npm ERR!                  from ../src/odbc.cpp:29:
npm ERR! ../../nan/nan.h:1746:3: note: declared here
npm ERR!  1746 |   Call(int argc, v8::Local<v8::Value> argv[]) const {
npm ERR!       |   ^~~~
npm ERR! ../src/odbc.cpp: In static member function 'static v8::Local<v8::Value> ODBC::CallbackSQLError(SQLSMALLINT, SQLHANDLE, char*, Nan::Callback*)':
npm ERR! ../src/odbc.cpp:1501:11: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
npm ERR!  1501 |   cb->Call(1, info);
npm ERR!       |   ~~~~~~~~^~~~~~~~~
npm ERR! In file included from ../src/odbc.h:23,
npm ERR!                  from ../src/odbc.cpp:29:
npm ERR! ../../nan/nan.h:1746:3: note: declared here
npm ERR!  1746 |   Call(int argc, v8::Local<v8::Value> argv[]) const {
npm ERR!       |   ^~~~
npm ERR! In file included from ../src/odbc.cpp:24:
npm ERR! ../src/odbc.cpp: At global scope:
npm ERR! /root/.cache/node-gyp/16.16.0/include/node/node.h:847:7: warning: cast between incompatible function types from 'void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)' {aka 'void (*)(v8::Local<v8::Object>)'} to 'node::addon_register_func' {aka 'void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)'} [-Wcast-function-type]
npm ERR!   847 |       (node::addon_register_func) (regfunc),                          \
npm ERR!       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /root/.cache/node-gyp/16.16.0/include/node/node.h:881:3: note: in expansion of macro 'NODE_MODULE_X'
npm ERR!   881 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
npm ERR!       |   ^~~~~~~~~~~~~
npm ERR! ../src/odbc.cpp:1665:1: note: in expansion of macro 'NODE_MODULE'
npm ERR!  1665 | NODE_MODULE(odbc_bindings, init)
npm ERR!       | ^~~~~~~~~~~
npm ERR! ../src/odbc.cpp: In static member function 'static v8::Local<v8::Value> ODBC::GetColumnValue(SQLHSTMT, Column, uint16_t*, size_t)':
npm ERR! ../src/odbc.cpp:598:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!   598 |         if(column.type == SQL_BIGINT)
npm ERR!       |         ^~
npm ERR! ../src/odbc.cpp:603:5: note: here
npm ERR!   603 |     case SQL_DBCLOB:
npm ERR!       |     ^~~~
npm ERR! ../src/odbc.cpp:604:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!   604 |         if(column.type == SQL_DBCLOB)
npm ERR!       |         ^~
npm ERR! ../src/odbc.cpp:609:5: note: here
npm ERR!   609 |     default :
npm ERR!       |     ^~~~~~~
npm ERR! ../src/odbc.cpp: In static member function 'static v8::Local<v8::Value> ODBC::GetOutputParameter(Parameter)':
npm ERR! ../src/odbc.cpp:772:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!   772 |         if(prm.type == SQL_NUMERIC)
npm ERR!       |         ^~
npm ERR! ../src/odbc.cpp:774:5: note: here
npm ERR!   774 |     case SQL_BIGINT :
npm ERR!       |     ^~~~
npm ERR! ../src/odbc.cpp:826:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!   826 |         if(prm.type == SQL_DECIMAL) {
npm ERR!       |         ^~
npm ERR! ../src/odbc.cpp:829:5: note: here
npm ERR!   829 |     case SQL_FLOAT :
npm ERR!       |     ^~~~
npm ERR! ../src/odbc.cpp:871:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!   871 |         if((int) prm.type == SQL_DBCLOB)
npm ERR!       |         ^~
npm ERR! ../src/odbc.cpp:875:5: note: here
npm ERR!   875 |     case SQL_BLOB :
npm ERR!       |     ^~~~
npm ERR! ../src/odbc.cpp:876:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!   876 |         if((int) prm.type == SQL_BLOB)
npm ERR!       |         ^~
npm ERR! ../src/odbc.cpp:880:5: note: here
npm ERR!   880 |     default :
npm ERR!       |     ^~~~~~~
npm ERR! make: *** [odbc_bindings.target.mk:120: Release/obj.target/odbc_bindings/src/odbc.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 5.10.93-0-virt
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build" "--IS_DOWNLOADED=true" "--IBM_DB_HOME=/root/node_modules/ibm_db/installer/clidriver"
npm ERR! gyp ERR! cwd /root/node_modules/ibm_db
npm ERR! gyp ERR! node -v v16.16.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok 
npm ERR! 
npm ERR!     at ChildProcess.exithandler (node:child_process:398:12)
npm ERR!     at ChildProcess.emit (node:events:527:28)
npm ERR!     at maybeClose (node:internal/child_process:1092:16)
npm ERR!     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) {
npm ERR!   code: 1,
npm ERR!   killed: false,
npm ERR!   signal: null,
npm ERR!   cmd: 'node-gyp configure build  --IS_DOWNLOADED=true --IBM_DB_HOME="$IBM_DB_HOME"'
npm ERR! }

npm ERR! A complete log of this run can be found in:
npm ERR!     /data/.npm/_logs/2022-11-21T16_23_48_280Z-debug-0.log
f6727d6f5e15:~# 
janvda commented 1 year ago

Going back to an older alpine/g++ fixed the issue as in that case I could install the package:

bash-5.0$ sudo su -
90f9e2f349d7:~#  npm install ibm_db

added 60 packages, and audited 61 packages in 47s

4 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm notice 
npm notice New major version of npm available! 8.1.2 -> 9.1.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.1.2
npm notice Run npm install -g npm@9.1.2 to update!
npm notice 
90f9e2f349d7:~#

So I don't have the error with following alpine / g++ compiler version:

90f9e2f349d7:~# uname -a
Linux 90f9e2f349d7 5.10.93-0-virt #1-Alpine SMP Thu, 27 Jan 2022 09:34:38 +0000 x86_64 Linux
90f9e2f349d7:~# g++ --version
g++ (Alpine 9.3.0) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

90f9e2f349d7:~# gcc --version
gcc (Alpine 9.3.0) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

90f9e2f349d7:~# 

FYI I have the error with following alpine / g++ compiler version:

bash-5.1$ uname -a
Linux f6727d6f5e15 5.10.93-0-virt #1-Alpine SMP Thu, 27 Jan 2022 09:34:38 +0000 x86_64 Linux

282110cdcbe7:~# which g++
/usr/bin/g++
282110cdcbe7:~# g++ --version
g++ (Alpine 11.2.1_git20220219) 11.2.1 20220219
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
282110cdcbe7:~# gcc --version
gcc (Alpine 11.2.1_git20220219) 11.2.1 20220219
janvda commented 1 year ago

I am having same issue when using docker image: node:19.1.0-alpine3.16

So I started container on my macbook pro with following command:

 docker run node:19.1.0-alpine3.16 sh -c 'while sleep 3600; do :; done'

I had to install following packages:

 apk add python3 make alpine-sdk

The error output:

/ # mkdir data
/ # cd /data
/data # npm install ibm_db
npm ERR! code 1
npm ERR! path /data/node_modules/ibm_db
npm ERR! command failed
npm ERR! command sh -c -- node installer/driverInstall.js
npm ERR! platform = linux, arch = x64, node.js version = v19.1.0
npm ERR! make version =GNU Make 4.3
npm ERR! 
npm ERR! ****************************************
npm ERR! You are downloading a package which includes the Node.js module for IBM DB2/Informix.  The module is licensed under the Apache License 2.0. The package also includes IBM ODBC and CLI Driver from IBM, which is automatically downloaded as the node module is installed on your system/device. The license agreement to the IBM ODBC and CLI Driver is available in /data/node_modules/ibm_db/installer/clidriver. Check for additional dependencies, which may come with their own license agreement(s). Your use of the components of the package and dependencies constitutes your acceptance of their respective license agreements. If you do not accept the terms of any license agreement(s), then delete the relevant component(s) from your device.
npm ERR! ****************************************
npm ERR! 
npm ERR! Downloading DB2 ODBC CLI Driver from https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz ...
npm ERR! 
100.00% | 25012651 bytes downloaded out of 25012651 bytes.
npm ERR! 
npm ERR! Downloading and extraction of DB2 ODBC CLI Driver completed successfully.
npm ERR! 
npm ERR! make: Entering directory '/data/node_modules/ibm_db/build'
npm ERR!   CXX(target) Release/obj.target/odbc_bindings/src/odbc.o
npm ERR! make: Leaving directory '/data/node_modules/ibm_db/build'
npm ERR! 
npm ERR! Error: Command failed: node-gyp configure build  --IS_DOWNLOADED=true --IBM_DB_HOME="$IBM_DB_HOME"
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.1.0
npm ERR! gyp info using node@19.1.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.10.8 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/data/node_modules/ibm_db/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.cache/node-gyp/19.1.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/19.1.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/19.1.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/data/node_modules/ibm_db',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/odbc.cpp:29:
npm ERR! ../src/odbc.h: In constructor 'ODBC::ODBC()':
npm ERR! ../src/odbc.h:142:23: error: cast from 'std::nullptr_t' to 'SQLHENV' {aka 'int'} loses precision [-fpermissive]
npm ERR!   142 |     ODBC() { m_hEnv = (SQLHENV)NULL; }
npm ERR!       |                       ^
npm ERR! ../src/odbc.cpp: In member function 'void ODBC::Free()':
npm ERR! ../src/odbc.cpp:110:14: error: cast from 'std::nullptr_t' to 'SQLHENV' {aka 'int'} loses precision [-fpermissive]
npm ERR!   110 |     m_hEnv = (SQLHENV)NULL;
npm ERR!       |              ^
npm ERR! ../src/odbc.cpp: In static member function 'static Nan::NAN_METHOD_RETURN_TYPE ODBC::New(Nan::NAN_METHOD_ARGS_TYPE)':
npm ERR! ../src/odbc.cpp:122:17: error: cast from 'std::nullptr_t' to 'SQLHENV' {aka 'int'} loses precision [-fpermissive]
npm ERR!   122 |   dbo->m_hEnv = (SQLHENV)NULL;
npm ERR!       |                 ^
npm ERR! ../src/odbc.cpp: In static member function 'static void ODBC::UV_AfterCreateConnection(uv_work_t*, int)':
npm ERR! ../src/odbc.cpp:216:19: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
npm ERR!   216 |     data->cb->Call(1, info);
npm ERR!       |     ~~~~~~~~~~~~~~^~~~~~~~~
npm ERR! In file included from ../src/odbc.h:23,
npm ERR!                  from ../src/odbc.cpp:29:
npm ERR! ../../nan/nan.h:1746:3: note: declared here
npm ERR!  1746 |   Call(int argc, v8::Local<v8::Value> argv[]) const {
npm ERR!       |   ^~~~
npm ERR! ../src/odbc.cpp:228:19: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
npm ERR!   228 |     data->cb->Call(2, info);
npm ERR!       |     ~~~~~~~~~~~~~~^~~~~~~~~
npm ERR! In file included from ../src/odbc.h:23,
npm ERR!                  from ../src/odbc.cpp:29:
npm ERR! ../../nan/nan.h:1746:3: note: declared here
npm ERR!  1746 |   Call(int argc, v8::Local<v8::Value> argv[]) const {
npm ERR!       |   ^~~~
npm ERR! ../src/odbc.cpp: In static member function 'static v8::Local<v8::Value> ODBC::CallbackSQLError(SQLSMALLINT, SQLHANDLE, char*, Nan::Callback*)':
npm ERR! ../src/odbc.cpp:1501:11: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
npm ERR!  1501 |   cb->Call(1, info);
npm ERR!       |   ~~~~~~~~^~~~~~~~~
npm ERR! In file included from ../src/odbc.h:23,
npm ERR!                  from ../src/odbc.cpp:29:
npm ERR! ../../nan/nan.h:1746:3: note: declared here
npm ERR!  1746 |   Call(int argc, v8::Local<v8::Value> argv[]) const {
npm ERR!       |   ^~~~
npm ERR! In file included from ../src/odbc.cpp:24:
npm ERR! ../src/odbc.cpp: At global scope:
npm ERR! /root/.cache/node-gyp/19.1.0/include/node/node.h:993:7: warning: cast between incompatible function types from 'void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)' {aka 'void (*)(v8::Local<v8::Object>)'} to 'node::addon_register_func' {aka 'void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)'} [-Wcast-function-type]
npm ERR!   993 |       (node::addon_register_func) (regfunc),                          \
npm ERR!       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /root/.cache/node-gyp/19.1.0/include/node/node.h:1027:3: note: in expansion of macro 'NODE_MODULE_X'
npm ERR!  1027 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
npm ERR!       |   ^~~~~~~~~~~~~
npm ERR! ../src/odbc.cpp:1665:1: note: in expansion of macro 'NODE_MODULE'
npm ERR!  1665 | NODE_MODULE(odbc_bindings, init)
npm ERR!       | ^~~~~~~~~~~
npm ERR! ../src/odbc.cpp: In static member function 'static v8::Local<v8::Value> ODBC::GetColumnValue(SQLHSTMT, Column, uint16_t*, size_t)':
npm ERR! ../src/odbc.cpp:598:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!   598 |         if(column.type == SQL_BIGINT)
npm ERR!       |         ^~
npm ERR! ../src/odbc.cpp:603:5: note: here
npm ERR!   603 |     case SQL_DBCLOB:
npm ERR!       |     ^~~~
npm ERR! ../src/odbc.cpp:604:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!   604 |         if(column.type == SQL_DBCLOB)
npm ERR!       |         ^~
npm ERR! ../src/odbc.cpp:609:5: note: here
npm ERR!   609 |     default :
npm ERR!       |     ^~~~~~~
npm ERR! ../src/odbc.cpp: In static member function 'static v8::Local<v8::Value> ODBC::GetOutputParameter(Parameter)':
npm ERR! ../src/odbc.cpp:772:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!   772 |         if(prm.type == SQL_NUMERIC)
npm ERR!       |         ^~
npm ERR! ../src/odbc.cpp:774:5: note: here
npm ERR!   774 |     case SQL_BIGINT :
npm ERR!       |     ^~~~
npm ERR! ../src/odbc.cpp:826:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!   826 |         if(prm.type == SQL_DECIMAL) {
npm ERR!       |         ^~
npm ERR! ../src/odbc.cpp:829:5: note: here
npm ERR!   829 |     case SQL_FLOAT :
npm ERR!       |     ^~~~
npm ERR! ../src/odbc.cpp:871:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!   871 |         if((int) prm.type == SQL_DBCLOB)
npm ERR!       |         ^~
npm ERR! ../src/odbc.cpp:875:5: note: here
npm ERR!   875 |     case SQL_BLOB :
npm ERR!       |     ^~~~
npm ERR! ../src/odbc.cpp:876:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
npm ERR!   876 |         if((int) prm.type == SQL_BLOB)
npm ERR!       |         ^~
npm ERR! ../src/odbc.cpp:880:5: note: here
npm ERR!   880 |     default :
npm ERR!       |     ^~~~~~~
npm ERR! make: *** [odbc_bindings.target.mk:120: Release/obj.target/odbc_bindings/src/odbc.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:201:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
npm ERR! gyp ERR! System Linux 5.10.93-0-virt
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build" "--IS_DOWNLOADED=true" "--IBM_DB_HOME=/data/node_modules/ibm_db/installer/clidriver"
npm ERR! gyp ERR! cwd /data/node_modules/ibm_db
npm ERR! gyp ERR! node -v v19.1.0
npm ERR! gyp ERR! node-gyp -v v9.1.0
npm ERR! gyp ERR! not ok 
npm ERR! 
npm ERR!     at ChildProcess.exithandler (node:child_process:419:12)
npm ERR!     at ChildProcess.emit (node:events:513:28)
npm ERR!     at maybeClose (node:internal/child_process:1098:16)
npm ERR!     at ChildProcess._handle.onexit (node:internal/child_process:304:5) {
npm ERR!   code: 1,
npm ERR!   killed: false,
npm ERR!   signal: null,
npm ERR!   cmd: 'node-gyp configure build  --IS_DOWNLOADED=true --IBM_DB_HOME="$IBM_DB_HOME"'
npm ERR! }

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-11-22T16_20_51_270Z-debug-0.log
/data # ^C
janvda commented 1 year ago

installing also didn't work when using alpine image : node:14.21.1-alpine3.16 installing works when using older alpine image : node:14-alpine3.14

bimalkjha commented 1 year ago

@janvda It seems duplicate of your another issue #895 . Thanks.

janvda commented 1 year ago

It is not exactly a duplicate as I could install it on older alpine version as I mentioned here above. So this issue I am only getting when using newer alpine versions. While issue #895 is reported for older alpine versions.

bimalkjha commented 1 year ago

@janvda The above compilation error is due to the difference in the header file of gcc on Alpine Linux and other Linux flavour. The gcc on Apline is /usr/lib/gcc/x86_64-alpine-linux-musl/ and if we check the /usr/include/stdlib.h file, the definition of NULL can be found as below:

#if __cplusplus >= 201103L
#define NULL nullptr
#elif defined(__cplusplus)
#define NULL 0L
#else
#define NULL ((void*)0)
#endif

We can not see file stddef.h include in /usr/include/stdlib.h on Alpine which has the correct definition of NULL. If we check /usr/include/stdlib.h file on other Linux flavor, we can see stddef.h is include in /usr/include/stdlib.h. The NULL in stddef.h is defined as below:

#ifdef __GNUG__
#define NULL __null
#else   /* G++ */
#ifndef __cplusplus
#define NULL ((void *)0)
#else   /* C++ */
#define NULL 0
#endif  /* C++ */
#endif  /* G++ */

We can fix the compilation error by just adding a line #define NULL 0 in ibm_db/src/odbc.h file and compilation would succeed. But, you wont be able to run any test program using ibm_db.

The reason is, ibm_db uses IBM ODBC and CLI Driver internally for communication with server and IBM Driver is not compiled using ld-musl-x86_64.so.1, but it is compiled using ld-linux-x86-64.so.2. To verify it, you can download https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz on Alpine Linux, untar it, cd to clidriver/bin directory and execute ./db2level. It will not run. ldd db2level command will give info about missing symbols.

Same problem you can see if you download https://nodejs.org/dist/v19.1.0/node-v19.1.0-linux-x64.tar.gz and try to use it. This node is also compiled using ld-linux-x86-64.so.2 and ldd node will show you the missing symbols. The node which get installed by apk add nodejs is compiled using ld-musl-x86_64.so.1, so it works on Alpine Linux.

Hence, as per previous comment https://github.com/ibmdb/node-ibm_db/issues/217#issuecomment-274738255, Alpine Linux is not a supported platform for node ibm_db. We have documented this limitation in the latest Readme.md file.

Hence, closing this issue. Thanks.