PX4-Autopilot: Unable to '"make px4_sitl gazebo"

I followed the instructions given here https://docs.px4.io/master/en/dev_setup/dev_env_linux_ubuntu.html to setup Gazebo and PX4. But when it try to run gazebo, it throws the following error.

Env: Ubuntu 20.04.3 LTS Virtual Machine Gazebo 11 ( d/led when I ran the https://github.com/PX4/PX4-Autopilot/blob/master/Tools/setup/ubuntu.sh script as mentioned in the docs.

– Found GStreamer: adding gst_video_stream_widget CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: Boost_INCLUDE_DIR used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo/unit_tests used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo/unit_tests used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo/unit_tests used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo/unit_tests used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo/unit_tests used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo/unit_tests used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo/unit_tests used as include directory in directory /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo/unit_tests – Configuring incomplete, errors occurred! See also “/home/VMuser/PX4-Autopilot/build/px4_sitl_default/build_gazebo/CMakeFiles/CMakeOutput.log”. See also “/home/VMuser/PX4-Autopilot/build/px4_sitl_default/build_gazebo/CMakeFiles/CMakeError.log”. [247/846] ROMFS: copying, generating airframes FAILED: external/Stamp/sitl_gazebo/sitl_gazebo-configure cd /home/VMuser/PX4-Autopilot/build/px4_sitl_default/build_gazebo && /usr/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DSEND_ODOMETRY_DATA=ON -DGENERATE_ROS_MODELS=ON -GNinja /home/VMuser/PX4-Autopilot/Tools/sitl_gazebo && /usr/bin/cmake -E touch /home/VMuser/PX4-Autopilot/build/px4_sitl_default/external/Stamp/sitl_gazebo/sitl_gazebo-configure [249/846] Generating parameters.xml ninja: build stopped: subcommand failed. make: *** [Makefile:235: px4_sitl] Error 1

The output of the CMakeError.log file is as follows:

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output: Change Dir: /home/VMuser/PX4-Autopilot/build/px4_sitl_default/build_gazebo/CMakeFiles/CMakeTmp

Run Build Command(s):/bin/ninja cmTC_f4056 && [1/2] Building C object CMakeFiles/cmTC_f4056.dir/src.c.o [2/2] Linking C executable cmTC_f4056 FAILED: cmTC_f4056 : && /bin/cc -DCMAKE_HAVE_LIBC_PTHREAD CMakeFiles/cmTC_f4056.dir/src.c.o -o cmTC_f4056 && : /bin/ld: CMakeFiles/cmTC_f4056.dir/src.c.o: in function main': src.c:(.text+0x46): undefined reference to pthread_create’ /bin/ld: src.c:(.text+0x52): undefined reference to pthread_detach' /bin/ld: src.c:(.text+0x63): undefined reference to pthread_join’ collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.

Source file was: #include <pthread.h>

void* test_func(void* data) { return data; }

int main(void) { pthread_t thread; pthread_create(&thread, NULL, test_func, NULL); pthread_detach(thread); pthread_join(thread, NULL); pthread_atfork(NULL, NULL, NULL); pthread_exit(NULL);

return 0; }

Determining if the function pthread_create exists in the pthreads failed with the following output: Change Dir: /home/VMuser/PX4-Autopilot/build/px4_sitl_default/build_gazebo/CMakeFiles/CMakeTmp

Run Build Command(s):/bin/ninja cmTC_21238 && [1/2] Building C object CMakeFiles/cmTC_21238.dir/CheckFunctionExists.c.o [2/2] Linking C executable cmTC_21238 FAILED: cmTC_21238 : && /bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_21238.dir/CheckFunctionExists.c.o -o cmTC_21238 -lpthreads && : /bin/ld: cannot find -lpthreads collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.

While the issue is similiar to #13759, re-downloading the gazebo plugins do not seem to make the difference. Moreover, running sudo apt-get install libprotobuf-dev libprotoc-dev protobuf-compiler libeigen3-dev libxml2-utils python-rospkg python-jinja2 throws the error (not sure if related to above error though) :

Package python-rospkg is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source However the following packages replace it: python3-rospkg

E: Package ‘python-rospkg’ has no installation candidate

Hence, I suspect the error could be Cmake files but I don’t have the sufficient know-how to fix it.

Any advice is appreciated.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 30 (14 by maintainers)

Most upvoted comments

@Jeswin17 please remove the build folder and try make px4_sitl gazebo again and paste the full output.

On my Ubuntu 20.04 I have:

java --version
openjdk 13.0.7 2021-04-20
OpenJDK Runtime Environment (build 13.0.7+5-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 13.0.7+5-Ubuntu-0ubuntu120.04, mixed mode, sharing)

And make px4_sitl jmavsim works.