ros2-java / ros2_java

Java and Android bindings for ROS2
Apache License 2.0
174 stars 93 forks source link

How do I compile ros2_java on ros2 foxy version? I have tried to compile and cannot pass #227

Open Qin-Yuan opened 2 years ago

schragnasher commented 1 year ago

I am unable to build as well.

--- stderr: rcljava
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp: In function ‘jlong Java_org_ros2_rcljava_subscription_statuses_MessageLost_nativeAllocateRCLStatusEvent(JNIEnv*, jclass)’:
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:30:28: error: ‘rmw_message_lost_status_t’ was not declared in this scope; did you mean ‘rmw_liveliness_lost_status_
’?
   30 |   void * p = malloc(sizeof(rmw_message_lost_status_t));
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                            rmw_liveliness_lost_status_t
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp: In function ‘void Java_org_ros2_rcljava_subscription_statuses_MessageLost_nativeFromRCLEvent(JNIEnv*, jobject, jlong)’:
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:49:31: error: ‘rmw_message_lost_status_t’ does not name a type; did you mean ‘rmw_liveliness_lost_status_t’?
   49 |   auto * p = reinterpret_cast<rmw_message_lost_status_t *>(handle);
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                               rmw_liveliness_lost_status_t
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:49:57: error: expected ‘>’ before ‘*’ token
   49 |   auto * p = reinterpret_cast<rmw_message_lost_status_t *>(handle);
      |                                                         ^
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:49:57: error: expected ‘(’ before ‘*’ token
   49 |   auto * p = reinterpret_cast<rmw_message_lost_status_t *>(handle);
      |                                                         ^
      |                                                         (
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:49:58: error: expected primary-expression before ‘>’ token
   49 |   auto * p = reinterpret_cast<rmw_message_lost_status_t *>(handle);
      |                                                          ^
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:49:67: error: expected ‘)’ before ‘;’ token
   49 |   auto * p = reinterpret_cast<rmw_message_lost_status_t *>(handle);
      |                                                                   ^
      |                                                                   )
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp: In function ‘jint Java_org_ros2_rcljava_subscription_statuses_MessageLost_nativeGetSubscriptionEventType(JNIEnv*, jclass)’:
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:73:10: error: ‘RCL_SUBSCRIPTION_MESSAGE_LOST’ was not declared in this scope
   73 |   return RCL_SUBSCRIPTION_MESSAGE_LOST;
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/org_ros2_rcljava_subscription_statuses__message_lost.dir/build.make:63: CMakeFiles/org_ros2_rcljava_subscription_statuses__message_lost.dir/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1598: CMakeFiles/org_ros2_rcljava_subscription_statuses__message_lost.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:141: all] Error 2
---
Failed   <<< rcljava [12.2s, exited with code 2]
Aborted  <<< nav_msgs [0.58s]
Aborted  <<< sensor_msgs [0.59s]
Aborted  <<< diagnostic_msgs [0.60s]
Aborted  <<< visualization_msgs [0.59s]
Aborted  <<< shape_msgs [0.60s]
Aborted  <<< trajectory_msgs [0.61s]

Summary: 22 packages finished [38.7s]
ceoifung commented 1 year ago

I am unable to build as well.

--- stderr: rcljava
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp: In function ‘jlong Java_org_ros2_rcljava_subscription_statuses_MessageLost_nativeAllocateRCLStatusEvent(JNIEnv*, jclass)’:
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:30:28: error: ‘rmw_message_lost_status_t’ was not declared in this scope; did you mean ‘rmw_liveliness_lost_status_
’?
   30 |   void * p = malloc(sizeof(rmw_message_lost_status_t));
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                            rmw_liveliness_lost_status_t
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp: In function ‘void Java_org_ros2_rcljava_subscription_statuses_MessageLost_nativeFromRCLEvent(JNIEnv*, jobject, jlong)’:
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:49:31: error: ‘rmw_message_lost_status_t’ does not name a type; did you mean ‘rmw_liveliness_lost_status_t’?
   49 |   auto * p = reinterpret_cast<rmw_message_lost_status_t *>(handle);
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                               rmw_liveliness_lost_status_t
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:49:57: error: expected ‘>’ before ‘*’ token
   49 |   auto * p = reinterpret_cast<rmw_message_lost_status_t *>(handle);
      |                                                         ^
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:49:57: error: expected ‘(’ before ‘*’ token
   49 |   auto * p = reinterpret_cast<rmw_message_lost_status_t *>(handle);
      |                                                         ^
      |                                                         (
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:49:58: error: expected primary-expression before ‘>’ token
   49 |   auto * p = reinterpret_cast<rmw_message_lost_status_t *>(handle);
      |                                                          ^
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:49:67: error: expected ‘)’ before ‘;’ token
   49 |   auto * p = reinterpret_cast<rmw_message_lost_status_t *>(handle);
      |                                                                   ^
      |                                                                   )
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp: In function ‘jint Java_org_ros2_rcljava_subscription_statuses_MessageLost_nativeGetSubscriptionEventType(JNIEnv*, jclass)’:
/home/josh/ros2_java_ws/src/ros2-java/ros2_java/rcljava/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp:73:10: error: ‘RCL_SUBSCRIPTION_MESSAGE_LOST’ was not declared in this scope
   73 |   return RCL_SUBSCRIPTION_MESSAGE_LOST;
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/org_ros2_rcljava_subscription_statuses__message_lost.dir/build.make:63: CMakeFiles/org_ros2_rcljava_subscription_statuses__message_lost.dir/src/main/cpp/org_ros2_rcljava_subscription_statuses_MessageLost.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1598: CMakeFiles/org_ros2_rcljava_subscription_statuses__message_lost.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:141: all] Error 2
---
Failed   <<< rcljava [12.2s, exited with code 2]
Aborted  <<< nav_msgs [0.58s]
Aborted  <<< sensor_msgs [0.59s]
Aborted  <<< diagnostic_msgs [0.60s]
Aborted  <<< visualization_msgs [0.59s]
Aborted  <<< shape_msgs [0.60s]
Aborted  <<< trajectory_msgs [0.61s]

Summary: 22 packages finished [38.7s]

same error, Do you resolve this error?