machines-in-motion / shared_memory

realtime interprocess communication
BSD 3-Clause "New" or "Revised" License
5 stars 1 forks source link

Export rt and pthread so depending packages have them #19

Closed luator closed 4 years ago

luator commented 4 years ago

Description

Code using the multi-process time series fails with a linker error unless rt and pthread are explicitly linked to, even if the corresponding code is not using any of them directly (see, for example, the demos in robot_interfaces).

It seems to me that this is caused by some dependency not exporting their dependency on these libraries correctly. I tried to trace it down to the lowest level in the dependency tree where these libraries are used which seems to be shared_memory. Indeed exporting them in the catkin_package command removes the need for explicitly linking against them in robot_interfaces.

I'm a bit unsure, though, if this is really the right place to fix this (hence only a draft PR for now). What is a bit confusing me is that shared_memory is already listed in catkin_package(LIBRARIES ...) which is linking against rt and pthread. I would have assumed that this is enough for depending packages but apparently it is not.

How I Tested

Just compiled.

Do not merge before

We agreed that this is the right way to do it.

luator commented 4 years ago

@vincentberenz what do you think?

vincentberenz commented 4 years ago

@luator

Maybe the issue occurs because some of shared_memory is header based, so the client library is the one making the linkage ? The update seems correct to me, but would be happy to also get @MaximilienNaveau opinion

luator commented 4 years ago

@MaximilienNaveau do you approve this? (I could overwrite this with my admin power but officially I need two approvals to merge :) ).