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

Custom message don't compile with -Wl,--no-undefined #213

Open
Rayman opened this issue Jun 18, 2024 · 1 comment
Open

Custom message don't compile with -Wl,--no-undefined #213

Rayman opened this issue Jun 18, 2024 · 1 comment

Comments

@Rayman
Copy link

Rayman commented Jun 18, 2024

Bug report

Required Info:

  • Operating System:
    Ubuntu 24.04
  • Installation type: binaries
  • Version or commit hash: 4.6.2-1noble.20240513.234614
  • DDS implementation: default
  • Client library (if applicable): N/A

Steps to reproduce issue

docker run -it ros:jazzy
cd && mkdir src && cd src
git clone https://github.com/Rayman/tutorial_interfaces.git
cd
colcon build

Expected behavior

Custom messages will compile with -Wl,--no-undefined linker flag.

Actual behavior

Starting >>> tutorial_interfaces
--- stderr: tutorial_interfaces                              
/usr/bin/ld: CMakeFiles/tutorial_interfaces_s__rosidl_typesupport_introspection_c.dir/rosidl_generator_py/tutorial_interfaces/_tutorial_interfaces_s.ep.rosidl_typesupport_introspection_c.c.o: in function `Py_XDECREF':
_tutorial_interfaces_s.ep.rosidl_typesupport_introspection_c.c:(.text+0x5a): undefined reference to `_Py_Dealloc'
/usr/bin/ld: CMakeFiles/tutorial_interfaces_s__rosidl_typesupport_introspection_c.dir/rosidl_generator_py/tutorial_interfaces/_tutorial_interfaces_s.ep.rosidl_typesupport_introspection_c.c.o: in function `_register_msg_type__msg__num':
_tutorial_interfaces_s.ep.rosidl_typesupport_introspection_c.c:(.text+0xc7): undefined reference to `PyCapsule_New'
...

Additional information

These errors indicate that the generated interfaces are not linked correctly to Python3. The solution would be to adjust the cmake files that the generated python interfaces are correctly linked.

I hope I'm filing this bug in the correct repo. If not, please point me in the right direction.

@Rayman
Copy link
Author

Rayman commented Jun 24, 2024

#140 changed the build to use FindPython3.cmake for building the python modules. This broke our packages that have -Wl,--no-undefined.

I'm not 100% sure but reading https://gitlab.kitware.com/cmake/cmake/-/issues/18100 it seems that python modules should not be linked to a python library, but instead use the symbols from the interpreter they are run from. This means the have undefined symbols by definition.

So do we want to:

  1. target_link_libraries the messages to Python3::Python which resolves the error
  2. Fix all packages that have -Wl,--no-undefined

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

1 participant