Repository navigation
Colcon build fails to undefined symbol: osrf_testing_tools_cpp #247
Copy link
Copy link
Open
Description
Greetings,
I followed the build instructions and got this error:
ld.lld: error: undefined symbol: osrf_testing_tools_cpp::memory_tools::on_unexpected_calloc(std::__ndk1::variant<std::__ndk1::function<void (osrf_testing_tools_cpp::memory_tools::MemoryToolsService&)>, std::__ndk1::function<void ()>, std::nullptr_t>)
>>> referenced by performance_test_fixture.cpp:57 (/home/x/ros2_android_ws/src/ros2/performance_test_fixture/src/performance_test_fixture.cpp:57)
>>> CMakeFiles/performance_test_fixture.dir/src/performance_test_fixture.cpp.o:(performance_test_fixture::PerformanceTest::SetUp(benchmark::State&))
ld.lld: error: undefined symbol: osrf_testing_tools_cpp::memory_tools::on_unexpected_malloc(std::__ndk1::variant<std::__ndk1::function<void (osrf_testing_tools_cpp::memory_tools::MemoryToolsService&)>, std::__ndk1::function<void ()>, std::nullptr_t>)
>>> referenced by performance_test_fixture.cpp:60 (/home/x/ros2_android_ws/src/ros2/performance_test_fixture/src/performance_test_fixture.cpp:60)
>>> CMakeFiles/performance_test_fixture.dir/src/performance_test_fixture.cpp.o:(performance_test_fixture::PerformanceTest::SetUp(benchmark::State&))
ld.lld: error: undefined symbol: osrf_testing_tools_cpp::memory_tools::on_unexpected_realloc(std::__ndk1::variant<std::__ndk1::function<void (osrf_testing_tools_cpp::memory_tools::MemoryToolsService&)>, std::__ndk1::function<void ()>, std::nullptr_t>)
>>> referenced by performance_test_fixture.cpp:63 (/home/x/ros2_android_ws/src/ros2/performance_test_fixture/src/performance_test_fixture.cpp:63)
>>> CMakeFiles/performance_test_fixture.dir/src/performance_test_fixture.cpp.o:(performance_test_fixture::PerformanceTest::SetUp(benchmark::State&))
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [CMakeFiles/performance_test_fixture.dir/build.make:103: libperformance_test_fixture.so] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:160: CMakeFiles/performance_test_fixture.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
---
Failed <<< performance_test_fixture [0.90s, exited with code 2]How should I resolve it?
I'm using ROS2 Humble, Ubuntu 22.04, Python 3.10.12. Android NDK r27b (27.1.12297006), Android 34 (I guess).
------------------------------------------------------------
Gradle 8.7
------------------------------------------------------------
Build time: 2024-03-22 15:52:46 UTC
Revision: 650af14d7653aa949fce5e886e685efc9cf97c10
Kotlin: 1.9.22
Groovy: 3.0.17
Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM: 21.0.4 (Oracle Corporation 21.0.4+8-LTS-274)
OS: Linux 6.8.0-45-generic amd64
There is a similar build error here (on macOS): ros2/ros2#1398
There is a plan B to use this: https://github.com/YasuChiba/ros2-android-build
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
Hyrtsi commentedon Oct 15, 2024
It looks like
performance_test_fixtureis a necessary package, because if we add it to--packages-ignorewe get:in building
tracetoolswhich is used forament_build_type_gradle.Hyrtsi commentedon Oct 15, 2024
I studied this a little bit more. You can see the actual code as in the repositories here: https://github.com/raw/ros2-java/ros2_java/main/ros2_java_android.repos
I built just the culprit and its dependencies. First a vanilla build (no crosscompile):
Output: lots of warnings like this:
and
and
but nonetheless the packages have been built. I could get rid of the
stderroutput like this:Next, if I do the cross compile (as in the README of this repo):
then build only these packages:
it actually succeeds. So the root problem isn't these packages, but which order they are built or something in my system or that some other packages are broken.
I tried this build script instead, but ran into another problem:
Note that this uses a different way to choose the packages. I suspect that the
--packages-up-tocan be changed to something else to build enough packages for my needs. Some of the packages are definitely obsolete and outdated.Hyrtsi commentedon Oct 15, 2024
Ok I got past that error. Instructions here. I just checked my java version:
and then chose which java I want. Then edited the variable
JAVA_HOME:to my desired Java version. Then I reran the build and got my next errors:
Indeed,
yields nothing, and I can't find anything related to that in
eProsima/Fast-CDR. It may be, that this header needs to be acquired from somewhere else. I did some searching and found out, that we are checked out to an ancient releasev1.0.20ofFast-CDR. I checked out to the latest release and it works.I got the same errors back about the
jni.h, and I "violently" added these include directories inros2-java/ros2_java/rcljava_common/CMakeLists.txt:then I got past everything else except this in
rcljava_commonpackage:I suspect a java version mismatch somewhere. I tried
but that didn't help.
Hyrtsi commentedon Oct 15, 2024
I may have to change the jdk version to something else.