Error during install: ‘::memchr’ has not been declared

See original GitHub issue

Description

When I try to install using npm install rclnodejs, it fails with:

error: ‘::memchr’ has not been declared

(full log below).

  • Library Version: latest from npm (0.21.3)
  • ROS Version: ros2 rolling
  • Platform / OS: Ubuntu 20.04.5
> npm version
{
  x: '1.0.0',
  npm: '8.15.0',
  node: '16.17.0',
  v8: '9.4.146.26-node.22',
  uv: '1.43.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.18.1',
  modules: '93',
  nghttp2: '1.47.0',
  napi: '8',
  llhttp: '6.0.7',
  openssl: '1.1.1q+quic',
  cldr: '41.0',
  icu: '71.1',
  tz: '2022a',
  unicode: '14.0',
  ngtcp2: '0.1.0-DEV',
  nghttp3: '0.1.0-DEV'
}

Steps To Reproduce

npm install rclnodejs

Expected Behavior

For it to install as described in the readme.

Actual Behavior

> npm install rclnodejs
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code 1
npm ERR! path /tmp/x/node_modules/rclnodejs
npm ERR! command failed
npm ERR! command sh /tmp/install-9ff58467.sh
npm ERR! make: Entering directory '/tmp/x/node_modules/rclnodejs/build'
npm ERR!   CXX(target) Release/obj.target/rclnodejs/src/addon.o
npm ERR! make: Leaving directory '/tmp/x/node_modules/rclnodejs/build'
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.17.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.8.10 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/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   '/tmp/x/node_modules/rclnodejs/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/cfritz/.cache/node-gyp/16.17.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=/home/cfritz/.cache/node-gyp/16.17.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/cfritz/.cache/node-gyp/16.17.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/tmp/x/node_modules/rclnodejs',
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 ../../nan/nan.h:64,
npm ERR!                  from ../src/addon.cpp:15:
npm ERR! /usr/include/c++/9/cstring:77:11: error: ‘::memchr’ has not been declared
npm ERR!    77 |   using ::memchr;
npm ERR!       |           ^~~~~~
npm ERR! /usr/include/c++/9/cstring:78:11: error: ‘::memcmp’ has not been declared
npm ERR!    78 |   using ::memcmp;
npm ERR!       |           ^~~~~~
npm ERR! /usr/include/c++/9/cstring:79:11: error: ‘::memcpy’ has not been declared
npm ERR!    79 |   using ::memcpy;
npm ERR!       |           ^~~~~~
npm ERR! /usr/include/c++/9/cstring:80:11: error: ‘::memmove’ has not been declared
npm ERR!    80 |   using ::memmove;
npm ERR!       |           ^~~~~~~
npm ERR! /usr/include/c++/9/cstring:81:11: error: ‘::memset’ has not been declared
npm ERR!    81 |   using ::memset;
npm ERR!       |           ^~~~~~
npm ERR! /usr/include/c++/9/cstring:82:11: error: ‘::strcat’ has not been declared
npm ERR!    82 |   using ::strcat;
npm ERR!       |           ^~~~~~
npm ERR! /usr/include/c++/9/cstring:83:11: error: ‘::strcmp’ has not been declared
npm ERR!    83 |   using ::strcmp;
npm ERR!       |           ^~~~~~
npm ERR! /usr/include/c++/9/cstring:84:11: error: ‘::strcoll’ has not been declared
npm ERR!    84 |   using ::strcoll;
npm ERR!       |           ^~~~~~~
npm ERR! /usr/include/c++/9/cstring:85:11: error: ‘::strcpy’ has not been declared
npm ERR!    85 |   using ::strcpy;
npm ERR!       |           ^~~~~~
npm ERR! /usr/include/c++/9/cstring:86:11: error: ‘::strcspn’ has not been declared
npm ERR!    86 |   using ::strcspn;
npm ERR!       |           ^~~~~~~
npm ERR! /usr/include/c++/9/cstring:87:11: error: ‘::strerror’ has not been declared
npm ERR!    87 |   using ::strerror;
npm ERR!       |           ^~~~~~~~
npm ERR! /usr/include/c++/9/cstring:88:11: error: ‘::strlen’ has not been declared
npm ERR!    88 |   using ::strlen;
npm ERR!       |           ^~~~~~
npm ERR! /usr/include/c++/9/cstring:89:11: error: ‘::strncat’ has not been declared
npm ERR!    89 |   using ::strncat;
npm ERR!       |           ^~~~~~~
npm ERR! /usr/include/c++/9/cstring:90:11: error: ‘::strncmp’ has not been declared
npm ERR!    90 |   using ::strncmp;
npm ERR!       |           ^~~~~~~
npm ERR! /usr/include/c++/9/cstring:91:11: error: ‘::strncpy’ has not been declared
npm ERR!    91 |   using ::strncpy;
npm ERR!       |           ^~~~~~~
npm ERR! /usr/include/c++/9/cstring:92:11: error: ‘::strspn’ has not been declared
npm ERR!    92 |   using ::strspn;
npm ERR!       |           ^~~~~~
npm ERR! /usr/include/c++/9/cstring:93:11: error: ‘::strtok’ has not been declared
npm ERR!    93 |   using ::strtok;
npm ERR!       |           ^~~~~~
npm ERR! /usr/include/c++/9/cstring:94:11: error: ‘::strxfrm’ has not been declared
npm ERR!    94 |   using ::strxfrm;
npm ERR!       |           ^~~~~~~
npm ERR! /usr/include/c++/9/cstring:95:11: error: ‘::strchr’ has not been declared
npm ERR!    95 |   using ::strchr;
npm ERR!       |           ^~~~~~
npm ERR! /usr/include/c++/9/cstring:96:11: error: ‘::strpbrk’ has not been declared
npm ERR!    96 |   using ::strpbrk;
npm ERR!       |           ^~~~~~~
npm ERR! /usr/include/c++/9/cstring:97:11: error: ‘::strrchr’ has not been declared
npm ERR!    97 |   using ::strrchr;
npm ERR!       |           ^~~~~~~
npm ERR! /usr/include/c++/9/cstring:98:11: error: ‘::strstr’ has not been declared
npm ERR!    98 |   using ::strstr;
npm ERR!       |           ^~~~~~
npm ERR! In file included from ../src/addon.cpp:15:
npm ERR! ../../nan/nan.h: In member function ‘void Nan::AsyncWorker::SetErrorMessage(const char*)’:
npm ERR! ../../nan/nan.h:2014:19: error: ‘strlen’ was not declared in this scope
npm ERR!  2014 |     size_t size = strlen(msg) + 1;
npm ERR!       |                   ^~~~~~
npm ERR! ../../nan/nan.h:410:1: note: ‘strlen’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
npm ERR!   409 | # include "nan_persistent_12_inl.h"  // NOLINT(build/include)
npm ERR!   +++ |+#include <cstring>
npm ERR!   410 | #else
npm ERR! ../../nan/nan.h:2016:5: error: ‘memcpy’ was not declared in this scope
npm ERR!  2016 |     memcpy(errmsg_, msg, size);
npm ERR!       |     ^~~~~~
npm ERR! ../../nan/nan.h:2016:5: note: ‘memcpy’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
npm ERR! In file included from ../../nan/nan.h:2797,
npm ERR!                  from ../src/addon.cpp:15:
npm ERR! ../../nan/nan_weak.h: In constructor ‘Nan::WeakCallbackInfo<P>::WeakCallbackInfo(Nan::Persistent<v8::Value>*, Nan::WeakCallbackInfo<P>::Callback, void*, void*, void*)’:
npm ERR! ../../nan/nan_weak.h:58:10: error: ‘memcpy’ is not a member of ‘std’; did you mean ‘memchr’?
npm ERR!    58 |     std::memcpy(&persistent_, persistent, sizeof (v8::Persistent<v8::Value>));
npm ERR!       |          ^~~~~~
npm ERR!       |          memchr
npm ERR! ../src/addon.cpp: In function ‘void InitModule(v8::Local<v8::Object>)’:
npm ERR! ../src/addon.cpp:48:16: error: ‘strstr’ was not declared in this scope; did you mean ‘std::strstr’?
npm ERR!    48 |     auto end = strstr(prog_name, " -");
npm ERR!       |                ^~~~~~
npm ERR!       |                std::strstr
npm ERR! In file included from ../../nan/nan.h:64,
npm ERR!                  from ../src/addon.cpp:15:
npm ERR! /usr/include/c++/9/cstring:118:3: note: ‘std::strstr’ declared here
npm ERR!   118 |   strstr(char* __s1, const char* __s2)
npm ERR!       |   ^~~~~~
npm ERR! make: *** [rclnodejs.target.mk:162: Release/obj.target/rclnodejs/src/addon.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/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 5.15.0-46-generic
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /tmp/x/node_modules/rclnodejs
npm ERR! gyp ERR! node -v v16.17.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
minggangwcommented, Oct 6, 2022

@chfritz @meropis finally, I hit this issue on 20.04 with g++9.4, and I have a workaround to mitigate this weird issue (it cannot be reproduced with 22.04…), please remove the following section from your binding.gyp

https://github.com/RobotWebTools/rclnodejs/blob/20c32f1307dde2fe057376c65cca2d0e0a14f3ec/binding.gyp#L71-L92

I will submit a PR to fix it and prepare a hotfix release, thanks!

0reactions
wayneparrottcommented, Sep 7, 2022

I’ve also noticed that there is no build status for galactic right now (see Readme), so I assume that combination is not currently being tested?

Opps! Thx for calling this out. Will get the status indicator fixed asap. The os/ros compatibility matrix are completing successfully for linux. https://github.com/RobotWebTools/rclnodejs/actions/runs/3009191104

Looks like a dependent action for setting up ros distros on windows is failing (again). Will give it a look asap. https://github.com/RobotWebTools/rclnodejs/runs/8232819051?check_suite_focus=true

Read more comments on GitHub >

github_iconTop Results From Across the Web

error: '::memchr' has not been declared · Issue #12 · ETLCPP/etl
Using the release version 8.2.0, the following file cannot be compiled with g++-5 -Ietl-8.2.0/src testetl.cpp -o testetl -std=c++11 using ...
Read more >
how do I fix some versioning issue when compiling C++ code?
When there is #include <cstring>. the g++ compiler should put the declarations it itself includes into the std:: AND the global namespaces.
Read more >
g++ include errors - LinuxQuestions.org
Hey, I'm trying to get up and running using Eclipse, but I cant even do the simplest program. Literally a program with an...
Read more >
#include<cstring> error help? - CodeGuru Forums
so when i include cstring so i can use the strlen i get this error In file ... has not been declared /usr/include/c++/4.3/cstring:81:...
Read more >
[GiNaC-list] problems with cstring and string
... from add.h:26, from add.cpp:23: /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/cstring:75:11: error: '::memchr' has not been declared ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found