Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chfritz opened this issue Sep 1, 2022 · 13 comments
Open

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

chfritz opened this issue Sep 1, 2022 · 13 comments

Comments

@chfritz
Copy link
Contributor

chfritz commented Sep 1, 2022

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 [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: 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 [email protected]: 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 [email protected]
npm ERR! gyp info using [email protected] | 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
@chfritz chfritz added the bug label Sep 1, 2022
@chfritz
Copy link
Contributor Author

chfritz commented Sep 1, 2022

I've discovered that npm install [email protected] works, so it seems that the issue was introduced recently.

@minggangw
Copy link
Member

Thanks for reporting the issue, through the error log, it seems that it happens when compiling the nan, do you try with Humble Hawksbill?

@chfritz
Copy link
Contributor Author

chfritz commented Sep 2, 2022

I haven't -- I'm on ubuntu 20 -- but the nan.h file is not from the OS but part of the npm nan package: https://github.com/nodejs/nan/blob/main/nan.h. So I don't think changing the ROS2 release would make a difference.

@minggangw
Copy link
Member

Yes, the header comes from nan package, theoretically, the behavior should be the same on different rclnodejs versions. I also checked the code change between these 2 versions, and it seems nothing special (we don't upgrade the nan version number). I will try to build it on my dev machine, but I believe it's caused by some toolchain env problem.

@meropis
Copy link

meropis commented Sep 5, 2022

I'm also having a similar issue
Ubuntu 22.04 LTS
Humble Hawkesbill

@minggangw
Copy link
Member

Would you try to upgrade your GCC to 11 and see if the failure is still there? I verified with the following configuration and it works fine:

  • nodejs: v16.16.0
  • g++: 11.2.0
  • OS: Ubuntu 22.04LTS

Meanwhile, looking through the latest build on actions, no failures were found.

@wayneparrott
Copy link
Collaborator

wayneparrott commented Sep 6, 2022

I noticed your env includes:

Platform / OS: Ubuntu 20.04.5

My understanding as of the Humble release, includes latest Rolling release, that Ubuntu 22 (jammy) is required. As a quick test I set up a new dev env with Ubuntu 22.04.01 (lts), Node 16 (lts) and rclnodejs from npm. No issues observed with rclnodejs installation and running simple node was successful. I repeated the process with the Humble release with success.

Hope this helps.

@chfritz
Copy link
Contributor Author

chfritz commented Sep 7, 2022

g++-11 is not available on 20.04 so I can't try that. 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? Another question: is there a reason why the repo doesn't include a package-lock.json? Without that, it's not deterministic which version of the dependencies was used in current and past npm releases. We could find out, of course, by inspecting the npm bundle, but wouldn't be able to reproduce it from the
tag commit alone.

@wayneparrott
Copy link
Collaborator

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

@minggangw
Copy link
Member

minggangw commented 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

rclnodejs/binding.gyp

Lines 71 to 92 in 20c32f1

'conditions': [
[
'ros_version > 2105', # Humble, Rolling, ...
{
'include_dirs':
[
"<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/ ') + '/include/')\")",
"<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcl/ ') + '/include/rcl')\")",
"<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcutils/ ') + '/include/rcutils/')\")",
"<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rmw/ ') + '/include/rmw/')\")",
"<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcl_yaml_param_parser/ ') + '/include/rcl_yaml_param_parser/')\")",
"<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rosidl_typesupport_interface/ ') + '/include/rosidl_typesupport_interface/')\")",
"<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcl_action/ ') + '/include/rcl_action/')\")",
"<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/action_msgs/ ') + '/include/action_msgs/')\")",
"<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/unique_identifier_msgs/ ') + '/include/unique_identifier_msgs/')\")",
"<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/builtin_interfaces/ ') + '/include/builtin_interfaces/')\")",
"<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcl_lifecycle/ ') + '/include/rcl_lifecycle/')\")",
"<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/lifecycle_msgs/ ') + '/include/lifecycle_msgs/')\")",
"<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rosidl_runtime_c/ ') + '/include/rosidl_runtime_c/')\")",
],
}
],

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

@chfritz
Copy link
Contributor Author

chfritz commented Jul 10, 2023

Sorry for the delay in testing this.

Removing the lines in binding.gyp indeed get me past the ::memchr error. But I'm getting:

> npm i

> [email protected] install
> npm run rebuild


> [email protected] rebuild
> npm run clean && node-gyp -j 16 rebuild


> [email protected] clean
> node-gyp clean && rimraf ./generated

make: Entering directory '/tmp/k/rclnodejs/build'
  CXX(target) Release/obj.target/rclnodejs/src/addon.o
  CXX(target) Release/obj.target/rclnodejs/src/executor.o
  CXX(target) Release/obj.target/rclnodejs/src/handle_manager.o
  CXX(target) Release/obj.target/rclnodejs/src/rcl_action_bindings.o
  CXX(target) Release/obj.target/rclnodejs/src/rcl_bindings.o
  CXX(target) Release/obj.target/rclnodejs/src/rcl_handle.o
  CXX(target) Release/obj.target/rclnodejs/src/rcl_lifecycle_bindings.o
  CXX(target) Release/obj.target/rclnodejs/src/rcl_utilities.o
  CXX(target) Release/obj.target/rclnodejs/src/shadow_node.o
../src/rcl_bindings.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE rclnodejs::CreateSubscription(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/rcl_bindings.cpp:715:23: error: ‘rcl_subscription_options_set_content_filter_options’ was not declared in this scope
  715 |       rcl_ret_t ret = rcl_subscription_options_set_content_filter_options(
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@chfritz
Copy link
Contributor Author

chfritz commented Jul 10, 2023

More details: when I use v0.21.2 then removing the lines from binding.gyp works on Ubuntu 20 (w/ rolling) but fails on Ubuntu 22. However, of course, 0.21.2 builds fine on Ubuntu 22 (w/ humble) unmodified.

@chfritz
Copy link
Contributor Author

chfritz commented Jul 10, 2023

Ok, so I've tested a whole matrix of combinations and finally realized that rolling on Ubuntu 20 is a different version from rolling on Ubuntu 22 (see here) and the condition in bindings.gyp isn't able to distinguish them . I'll try to come up with a better condition.

PS: If I can. Seems like there are other issues with compiling against rolling on u20 as well:

../src/rcl_bindings.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE rclnodejs::CreateSubscription(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/rcl_bindings.cpp:715:23: error: ‘rcl_subscription_options_set_content_filter_options’ was not declared in this scope
  715 |       rcl_ret_t ret = rcl_subscription_options_set_content_filter_options(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants