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

Gazebo7 Linking Error with CMake / Catkin - pthreads #2198

Closed
osrf-migration opened this issue Feb 14, 2017 · 10 comments
Closed

Gazebo7 Linking Error with CMake / Catkin - pthreads #2198

osrf-migration opened this issue Feb 14, 2017 · 10 comments
Labels
bug Something isn't working build major

Comments

@osrf-migration
Copy link

Original report (archived issue) by Dave Coleman (Bitbucket: Dave Coleman).


Based on discussions with @j-rivero on this gazebo_ros_pkgs pull request, I've isolated some sort of flag export build problem that results in the error:

CMake Error at /home/dave/ros/current/ws_gazebo_test/devel_release/share/base_pkg/cmake/base_pkgConfig.cmake:141 (message):
  Project 'dummy_pkg' tried to find library '-lpthread'.  The library is
  neither a target nor built/installed properly.  Did you compile project
  'base_pkg'? Did you find_package() it before the subdirectory containing
  its code is included?
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  CMakeLists.txt:6 (find_package)

I think the problem is Gazebo7 is exporting a dependency on pthread which is suggested is bad on StackOverflow.

This occurs when one catkin package depends on Gazebo, and another depends on that package:

base_pkg CMakeLists

cmake_minimum_required(VERSION 2.8.3)
project(base_pkg)

find_package(catkin REQUIRED COMPONENTS
  roscpp
)

find_package(GAZEBO REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GAZEBO_CXX_FLAGS}")

find_package(Boost REQUIRED COMPONENTS thread)

include_directories(
  ${catkin_INCLUDE_DIRS}
)

catkin_package(
  DEPENDS
    Boost
    GAZEBO
)

dependent pkg CMakeLists

cmake_minimum_required(VERSION 2.8.3)
project(dummy_pkg)

find_package(catkin REQUIRED COMPONENTS
  base_pkg
)

include_directories(
  ${catkin_INCLUDE_DIRS}
)

catkin_package(
  CATKIN_DEPENDS
    base_pkg
)

The full workspace can be tested from this barebones test repo I've just created.

Let me know how to fix this. This will also fix the Jenkins build failures on all gazebo_ros_pkgs pull requests.

@osrf-migration
Copy link
Author

Original comment by Dave Coleman (Bitbucket: Dave Coleman).


  • Edited issue description* set assignee to "wjwwood (Bitbucket: wjwwood, GitHub: wjwwood)"
  • set assignee_account_id to "557058:d06abb4a-3b31-45df-9e97-2b48a039ff16"

@osrf-migration
Copy link
Author

Original comment by Jose Luis Rivero (Bitbucket: Jose Luis Rivero, GitHub: j-rivero).


  • changed assignee_account_id from "557058:d06abb4a-3b31-45df-9e97-2b48a039ff16" to "557058:155a32e2-420c-4d50-98e0-0e722f63f906"
  • changed assignee from "wjwwood (Bitbucket: wjwwood, GitHub: wjwwood)" to "jrivero (Bitbucket: jrivero, GitHub: j-rivero)"

With William's permission, I will take care of finding the proper fix.

@osrf-migration
Copy link
Author

Original comment by Jose Luis Rivero (Bitbucket: Jose Luis Rivero, GitHub: j-rivero).


I debug the issue until the point on locating the problem in gazebo dependency on Protobuf. Going deeper in Protobuf, ¿@davetcoleman could you please temporary delete this line in FindProtobuf.cmake (probably located in your /usr/share/cmake-3.5/Modules/ directory) and run your build system to check if that fixes the issue?

We have built a lot of third party software on top of Gazebo so it should be related to catkin packages somehow.

@osrf-migration
Copy link
Author

Original comment by Dave Coleman (Bitbucket: Dave Coleman).


Indeed that fixed the build problem! Now how do we resolve it in a better way?

@osrf-migration
Copy link
Author

Original comment by Jose Luis Rivero (Bitbucket: Jose Luis Rivero, GitHub: j-rivero).


That is a good question, we need to know if any package using protobuf will generate that error or if the gazebo cmake config file is doing something funky that it is making catkin to fail. I think that we can move the issue to the catkin issue tracker and keep the discussion there.

@osrf-migration
Copy link
Author

Original comment by Dave Coleman (Bitbucket: Dave Coleman).


I'm not sure how to setup a protobuf test, I never use that library.

Move the issue here?

@osrf-migration
Copy link
Author

Original comment by Jose Luis Rivero (Bitbucket: Jose Luis Rivero, GitHub: j-rivero).


I think that we can keep the test case as it is, using Gazebo. The gazebo cmake config file is not difficult to understand. Yes, submit the bug to that URL since I think that it has more to do with catkin than with gazebo itself.

@osrf-migration
Copy link
Author

Original comment by Johannes Meyer (Bitbucket: johmeyer).


Just wanted to note that the gazebo_dev package introduced in ros-simulation/gazebo_ros_pkgs#473 would probably solve this issue and already implements the "create an extras file that finds gazebo and add it to the exported libraries of your package manually" approach proposed by @wjwwood.

Depending on gazebo_dev in find_package(catkin REQUIRED COMPONENTS ...) is sufficient for derived packages like gazebo_plugins or gazebo_ros_control. The cmake extras script will forward all include dirs and libraries as returned by the Gazebo CMake config and update the CMAKE_CXX_FLAGS variable. gazebo_dev also can be exported via catkin_package(CATKIN_DEPENDS gazebo_dev) if dependent packages should inherit the gazebo library dependency.

@osrf-migration
Copy link
Author

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


  • set component to "build"

@osrf-migration
Copy link
Author

Original comment by Jose Luis Rivero (Bitbucket: Jose Luis Rivero, GitHub: j-rivero).


  • changed state from "new" to "wontfix"

We are handling the problem in gazebo_ros_pkgs and catkin, I think that we don't have to do anything in the upstream code. Thanks Dave and Johannes for the information.

@osrf-migration osrf-migration added major build bug Something isn't working labels Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build major
Projects
None yet
Development

No branches or pull requests

1 participant