RobotWebTools / rclnodejs

Node.js version of ROS 2.0 client
https://docs.ros.org/en/humble/Concepts/Basic/About-Client-Libraries.html?highlight=rclnodejs#community-maintained
Apache License 2.0
311 stars 70 forks source link

librcl.so: cannot open shared object file: No such file or directory #943

Open Mithilesh982 opened 7 months ago

Mithilesh982 commented 7 months ago

Description I'm built a web app using React as frontend and node.js as backend , to connect ros2 and my nodejs im using rclnodejs but while running the code error is showing like : server/node_modules/bindings/bindings.js:121 throw e; ^ Error: librcl.so: cannot open shared object file: No such file or directory at Module._extensions..node (node:internal/modules/cjs/loader:1473:18) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Module.require (node:internal/modules/cjs/loader:1235:19) at require (node:internal/modules/helpers:176:18) at bindings (/home/eric/CUB-E_frontent_r2/server/node_modules/bindings/bindings.js:112:48) at Object. (/home/eric/CUB-E_frontent_r2/server/node_modules/rclnodejs/lib/clock.js:17:38) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) { code: 'ERR_DLOPEN_FAILED' } -node : v20.10.0

Steps To Reproduce

const rclnodejs = require('rclnodejs') rclnodejs.init().then(()=>{ const node = new rclnodejs.Node('ros2_connectivity_turtlebot3'); const publisher = rclnodejs.createPublisher('std_msgs/msg/String','cmd_vel ') publisher.publish('Hello from react server')

node.spin()

})

Expected Behavior srever running on 4000

Actual Behavior error

minggangw commented 7 months ago

It seem that the ld doesn't find the librcl.so, please check echo $LD_LIBRARY_PATH to see if the ROS2 lib path is there?

Mithilesh982 commented 7 months ago

It seem that the ld doesn't find the librcl.so, please check echo $LD_LIBRARY_PATH to see if the ROS2 lib path is there?

Ros2 lib is path Setup correctly, Thanks for your time . The error occurred because of nodejs version 20.x , rclnodejs version is only compatible with nodejs version 10.23.1 - 19.x. , so I just reinstall 19.x version and it solved the error.

You can see the full installation of rclnodejs from scratch https://github.com/ros2/ros2/blob/master/ros2.repos.

minggangw commented 7 months ago

I'm using nodejs v20.9.0, but didn't meet this error. Not sure why it doesn't work on your env.