I'm having trouble linking libraries in ROS2. I have a simple example posted here
I have two packages. awesome_library
defines a C++ class in a library and fantastic_node
defines a C++ executable that instantiates the class from awesome_library
.
I am familiar with how to do this in ROS1, but in ROS2 I am getting the following error.
[ 50%] Linking CXX executable fantastic_node_node
CMakeFiles/fantastic_node_node.dir/src/fnode.cpp.o: In function `main':
fnode.cpp:(.text+0x17d): undefined reference to `awesome_library::Awesomeness::Awesomeness()'
collect2: error: ld returned 1 exit status
CMakeFiles/fantastic_node_node.dir/build.make:177: recipe for target 'fantastic_node_node' failed
make[2]: *** [fantastic_node_node] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/fantastic_node_node.dir/all' failed
From the command ament build --only-packages awesome_library fantastic_node
I've tried a couple different variations of the library installation in awesome_library
and target linking in fantastic_node
but have not found one that works, or a similar example.
Current attempts with allenh1's branch:
ros-bouncy-ament-tools:
Installed: 0.5.0-0bionic.20180719.223430
Candidate: 0.5.0-0bionic.20180719.223430
Version table:
*** 0.5.0-0bionic.20180719.223430 500
500 http://repo.ros2.org/ubuntu/main bionic/main amd64 Packages
100 /var/lib/dpkg/status
! ros2_ws/ > apt-cache policy python3-colcon-core
python3-colcon-core:
Installed: 0.3.12-1
Candidate: 0.3.12-1
Version table:
*** 0.3.12-1 500
500 http://repo.ros2.org/ubuntu/main bionic/main amd64 Packages
500 http://repo.ros2.org/ubuntu/main bionic/main arm64 Packages
100 /var/lib/dpkg/status
! ros2_ws/ > colcon build --packages-select awesome_library fantastic_node --symlink-install
Starting >>> awesome_library
Finished <<< awesome_library [0.27s]
Starting >>> fantastic_node
--- stderr: fantastic_node
CMakeFiles/fantastic_node_node.dir/src/fnode.cpp.o: In function `main':
fnode.cpp:(.text+0x17d): undefined reference to `awesome_library::Awesomeness::Awesomeness()'
collect2: error: ld returned 1 exit status
make[2]: *** [fantastic_node_node] Error 1
make[1]: *** [CMakeFiles/fantastic_node_node.dir/all] Error 2
make: *** [all] Error 2
---
Failed <<< fantastic_node [ Exited with code 2 ]
Summary: 1 package finished [0.75s]
1 package failed: fantastic_node
1 package had stderr output: fantastic_node
[0.860s] ERROR:colcon.colcon_notification.desktop_notification:Exception in desktop notification extension 'notify2': org.freedesktop.Notifications.MaxNotificationsExceeded: Exceeded maximum number of notifications
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/colcon_notification/desktop_notification/__init__.py", line 107, in notify
title=title, message=message, icon_path=icon_path)
File "/usr/lib/python3/dist-packages/colcon_notification/desktop_notification/notify2.py", line 50, in notify
self._last_notification.show()
File "/usr/lib/python3/dist-packages/notify2.py", line 188, in show
self.timeout, # expire_timeout
File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 70, in __call__
return self._proxy_method(*args, **keywords)
File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in __call__
**keywords)
File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.Notifications.MaxNotificationsExceeded: Exceeded maximum number of notifications
Originally posted by David Lu on ROS Answers with karma: 10932 on 2018-11-01
Post score: 1
Original comments
Comment by gvdhoorn on 2018-11-01:
Unfortunately, GHFM doesn't work here :(