Getting C/C++ error when installing 2.0.3 version on MacOS
- mq-mqi-nodejs version: 2.0.3
- IBM MQ client version: 9.3.5.0 (from dspmqver)
- xcode-select version: 2403
- MacOS version: Sonoma 14.1.1
I am attempting to upgrade my local development environment on MacOS to the latest version. Whenever I run sudo npm -g install [email protected] I get the following errors:
npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/ibmmq
npm ERR! command failed
npm ERR! command sh -c node-gyp-build
npm ERR! CC(target) Release/obj.target/nothing/node_modules/node-addon-api/nothing.o
npm ERR! LIBTOOL-STATIC Release/nothing.a
npm ERR! CXX(target) Release/obj.target/ibmmq_native/src/mqi.o
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | darwin | x64
npm ERR! gyp info find Python using Python version 3.12.0 found at "/Library/Frameworks/Python.framework/Versions/3.12/bin/python3"
npm ERR! gyp info spawn /Library/Frameworks/Python.framework/Versions/3.12/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/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 '/usr/local/lib/node_modules/ibmmq/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/ap677/Library/Caches/node-gyp/20.11.1/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=/Users/ap677/Library/Caches/node-gyp/20.11.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/ap677/Library/Caches/node-gyp/20.11.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/usr/local/lib/node_modules/ibmmq',
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! warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
npm ERR! ../src/mqi.cc:492:19: error: reference to 'hex' is ambiguous
npm ERR! line[o++] = hex[p[j] >> 4];
npm ERR! ^
npm ERR! ../src/mqi.cc:53:20: note: candidate found by name lookup is 'hex'
npm ERR! static const char *hex = "0123456789ABCDEF";
npm ERR! ^
npm ERR! /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/ios:1004:1: note: candidate found by name lookup is 'std::hex'
npm ERR! hex(ios_base& __str)
npm ERR! ^
npm ERR! ../src/mqi.cc:493:19: error: reference to 'hex' is ambiguous
npm ERR! line[o++] = hex[p[j] & 0x0F];
npm ERR! ^
npm ERR! ../src/mqi.cc:53:20: note: candidate found by name lookup is 'hex'
npm ERR! static const char *hex = "0123456789ABCDEF";
npm ERR! ^
npm ERR! /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/ios:1004:1: note: candidate found by name lookup is 'std::hex'
npm ERR! hex(ios_base& __str)
npm ERR! ^
npm ERR! 2 errors generated.
npm ERR! make: *** [Release/obj.target/ibmmq_native/src/mqi.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/node-gyp/lib/build.js:203:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:518:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm ERR! gyp ERR! System Darwin 23.1.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /usr/local/lib/node_modules/ibmmq
npm ERR! gyp ERR! node -v v20.11.1
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok
I ran the install using Node 20.10.0, 20.11.1 and 20.12.0. All end with the same error. This error does not occur when installing the package into our Docker image that is based on node-bullseye-20. This uses Debian Linux.
It would appear the use of hex in this case is a coding error the for MacOS C compiler. Please advise.
Thanks, Jim
Got same issue on node 18.20.2 for 2.x.x ibmmq releases. I'm on Sonoma 14.4.1.
works for me, although I don't install globally: node : v18.17.1 Sonoma : 14.4 ibmmq : 2.0.3
gcc --version Apple clang version 15.0.0 (clang-1500.3.9.4) Target: arm64-apple-darwin23.4.0 Thread model: posix
It doesn't happen on my machine, but I deliberately don't keep up with the latest compiler changes - bumping versions can mean that compiled binaries no longer run on slightly older systems.
I guess that something in the newer compiler/SDK has either changed to pull in an additional package from the standard libraries, or that there's something changed in how it resolves names.
The only thing that is likely to work is to change the hex in mqi.cc to something like hexChars. I can make that change for the next iteration of the package, but for now, you'd have to edit the file yourself.
Mark, confirming that I ran the install of version 2.0.4 on my Mac and it works for me, now. Thanks for making the update!