Skip to content

Commit

Permalink
CMake: explicitly link the atomic library
Browse files Browse the repository at this point in the history
For arm & mips architecture, the linker must explicitly be asked to
link the atomic library (with `-latomic`).

Otherwise, the linking fails with:

```
| devel/lib/libmavros.so: undefined reference to `__atomic_load_8'
| devel/lib/libmavros.so: undefined reference to `__atomic_store_8'
| collect2: error: ld returned 1 exit status
```

Linking `atomic` unconditionally as library is strictly needed only
for arm & mips, but it seems not to imply any further differences
with other architectures. Hence, this commit simply adds `atomic`
unconditionally for a uniform handling of all machine architectures.

This is an alternative solution to the proposed solution in mavlink#790.

The issue was discovered cross-compiling mavros in meta-ros, the
OpenEmbedded layer for ROS. Some further pointers are available at:

  ros/meta-ros#525

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
  • Loading branch information
bulwahn committed Aug 30, 2017
1 parent 76abbff commit fc39484
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions mavros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ add_library(mavros
src/lib/rosconsole_bridge.cpp
)
target_link_libraries(mavros
atomic
${catkin_LIBRARIES}
${Boost_LIBRARIES}
${GeographicLib_LIBRARIES}
Expand Down

0 comments on commit fc39484

Please sign in to comment.