Ubuntu 20.04 编译 Apache Mesos 1.9.0 过程中遇到的问题

本文解决了在Linux环境下编译Mesos项目时遇到的两个常见错误:unnecessary parentheses in declaration of ‘assert_arg’ 和 ambiguating new declaration of ‘long int gettid()’。通过修改配置文件和源代码,成功解决了这些问题。

环境说明

Linux local-wwj-icu 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

g++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

error: unnecessary parentheses in declaration of ‘assert_arg’ [-Werror=parentheses]

日志片段

make  all-am
make[2]: Entering directory '/home/wuweijie/mesos/mesos-1.9.0/build/src'
g++ -DPACKAGE_NAME=\"mesos\" -DPACKAGE_TARNAME=\"mesos\" -DPACKAGE_VERSION=\"1.9.0\" -DPACKAGE_STRING=\"mesos\ 1.9.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"mesos\" -DVERSION=\"1.9.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_CXX11=1 -DHAVE_PTHREAD_PRIO_INHERIT=1 -DHAVE_PTHREAD=1 -DHAVE_FTS_H=1 -DHAVE_APR_POOLS_H=1 -DHAVE_LIBAPR_1=1 -DHAVE_LIBCURL=1 -DMESOS_HAS_JAVA=1 -DHAVE_LIBSASL2=1 -DHAVE_SVN_VERSION_H=1 -DHAVE_LIBSVN_SUBR_1=1 -DHAVE_SVN_DELTA_H=1 -DHAVE_LIBSVN_DELTA_1=1 -DHAVE_ZLIB_H=1 -DHAVE_LIBZ=1 -DHAVE_PYTHON=\"2.7\" -DMESOS_HAS_PYTHON=1 -I. -I../../src   -Werror -DLIBDIR=\"/usr/local/lib\" -DPKGLIBEXECDIR=\"/usr/local/libexec/mesos\" -DPKGDATADIR=\"/usr/local/share/mesos\" -DPKGMODULEDIR=\"/usr/local/lib/mesos/modules\" -I../../include -I../include -I../include/mesos -D__STDC_FORMAT_MACROS -I../3rdparty/boost-1.65.0 -I../3rdparty/concurrentqueue-7b69a8f -I../3rdparty/elfio-3.2 -I../3rdparty/glog-0.4.0/src -I../3rdparty/grpc-1.10.0/include -I../3rdparty/leveldb-1.19/include -I../3rdparty/libarchive-3.3.2/libarchive/ -I../../3rdparty/libprocess/include  -I../3rdparty/nvml-352.79 -I../3rdparty/picojson-1.3.0 -I../3rdparty/protobuf-3.5.0/src -I../3rdparty/rapidjson-1.1.0/include -I../../3rdparty/stout/include -I../3rdparty/zookeeper-3.4.8/src/c/include -I../3rdparty/zookeeper-3.4.8/src/c/generated -I/usr/include/subversion-1 -I/usr/include/apr-1 -I/usr/include/apr-1.0	       -pthread -Wall -Wsign-compare -Wformat-security -fstack-protector-strong -fPIC -fPIE -g1 -O0 -Wno-unused-local-typedefs -std=c++11 -MT local/mesos_local-main.o -MD -MP -MF local/.deps/mesos_local-main.Tpo -c -o local/mesos_local-main.o `test -f 'local/main.cpp' || echo '../../src/'`local/main.cpp
In file included from ../3rdparty/boost-1.65.0/boost/mpl/aux_/na_assert.hpp:23,
                 from ../3rdparty/boost-1.65.0/boost/mpl/arg.hpp:25,
                 from ../3rdparty/boost-1.65.0/boost/mpl/placeholders.hpp:24,
                 from ../3rdparty/boost-1.65.0/boost/iterator/iterator_categories.hpp:17,
                 from ../3rdparty/boost-1.65.0/boost/iterator/iterator_facade.hpp:14,
                 from ../3rdparty/boost-1.65.0/boost/range/iterator_range_core.hpp:27,
                 from ../3rdparty/boost-1.65.0/boost/lexical_cast.hpp:30,
                 from ../../3rdparty/stout/include/stout/numify.hpp:19,
                 from ../../3rdparty/stout/include/stout/bytes.hpp:24,
                 from ../../3rdparty/stout/include/stout/os.hpp:31,
                 from ../../src/local/main.cpp:22:
../3rdparty/boost-1.65.0/boost/mpl/assert.hpp:188:21: error: unnecessary parentheses in declaration of ‘assert_arg’ [-Werror=parentheses]
  188 | failed ************ (Pred::************
      |                     ^
../3rdparty/boost-1.65.0/boost/mpl/assert.hpp:193:21: error: unnecessary parentheses in declaration of ‘assert_not_arg’ [-Werror=parentheses]
  193 | failed ************ (boost::mpl::not_<Pred>::************
      |                     ^
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:11037: local/mesos_local-main.o] Error 1
make[2]: Leaving directory '/home/wuweijie/mesos/mesos-1.9.0/build/src'
make[1]: *** [Makefile:4742: all] Error 2
make[1]: Leaving directory '/home/wuweijie/mesos/mesos-1.9.0/build/src'
make: *** [Makefile:790: all-recursive] Error 1

具体错误

../3rdparty/boost-1.65.0/boost/mpl/assert.hpp:188:21: error: unnecessary parentheses in declaration of ‘assert_arg’ [-Werror=parentheses]
  188 | failed ************ (Pred::************
      |                     ^
../3rdparty/boost-1.65.0/boost/mpl/assert.hpp:193:21: error: unnecessary parentheses in declaration of ‘assert_not_arg’ [-Werror=parentheses]
  193 | failed ************ (boost::mpl::not_<Pred>::************
      |                     ^
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:11037: local/mesos_local-main.o] Error 1

解决方案

修改 mesos-1.9.0/src/Makefile.am 文件,将 MESOS_CPPFLAGS += @WERROR@ 注释。
在这里插入图片描述


error: ambiguating new declaration of ‘long int gettid()’

问题描述

该问题在编译 gRPC 过程中发生。
相关 Issue

解决方案

直接进入 gRPC 源码包修改源码:

vim 3rdparty/grpc-1.10.0.tar.gz

需要修改以下两个文件:

  • grpc-1.10.0/src/core/lib/gpr/log_posix.cc
  • grpc-1.10.0/src/core/lib/gpr/log_linux.cc

将文件中的 gettid 函数声明及调用的地方重命名为 sys_gettid

在这里插入图片描述

<think>我们正在处理用户的问题:“我想在Ubuntu 20.04编译通过ROS Navigation功能 请问Ubuntu 20.04 compile ROS Navigation success” 根据用户的问题,我们需要提供在Ubuntu 20.04上成功编译ROS Navigation功能的步骤。注意,ROS Navigation通常指的是ROS中的导航栈(navigation stack),它包含在ROS的导航包中。 首先,我们需要明确用户使用的ROS版本。Ubuntu 20.04对应的是ROS Noetic Ninjemys,这是ROS1的最后一个版本。因此,我们将基于ROS Noetic进行说明。 步骤大致如下: 1. 确保已经安装了ROS Noetic桌面完整版(推荐,因为包含了导航栈所需的许多依赖)。 2. 创建一个工作空间(如果已有可以跳过)。 3. 下载导航栈的源代码(或者通过apt安装二进制包,但用户要求编译,所以我们将从源代码编译)。 4. 解决依赖。 5. 编译。 注意:导航栈包含多个包,如amcl, move_base, map_server等。我们可以通过源代码编译整个导航栈。 然而,用户可能希望自己编译最新的版本(例如从GitHub上获取最新的代码),或者修改代码。因此,我们将介绍从源代码编译的方法。 但是,需要注意的是,ROS Noetic的导航包在官方源中已经提供了二进制包。如果用户不需要修改代码,直接安装二进制包是最简单的。不过,既然用户要求编译,我们将从源码编译。 具体步骤:</think>### 在 Ubuntu 20.04编译 ROS Navigation 功能指南 #### 前置条件 1. **已安装 ROS Noetic** Ubuntu 20.04 对应 ROS Noetic 版本,需先完成基础安装: ```bash sudo sh -c &#39;echo "deb http://packages.ros.org/ros/ubuntu focal main" > /etc/apt/sources.list.d/ros-latest.list&#39; sudo apt install curl curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - sudo apt update sudo apt install ros-noetic-desktop-full echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc source ~/.bashrc ``` 2. **创建工作空间** ```bash mkdir -p ~/catkin_ws/src cd ~/catkin_ws/ catkin_make echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc source ~/.bashrc ``` #### 编译 Navigation 功能包 1. **安装依赖** ```bash sudo apt install ros-noetic-navigation ros-noetic-move-base ros-noetic-amcl \ ros-noetic-map-server ros-noetic-dwa-local-planner ``` 2. **从源码编译(可选)** 若需最新版本或自定义修改: ```bash cd ~/catkin_ws/src git clone https://github.com/ros-planning/navigation.git -b noetic-devel cd .. rosdep install --from-paths src --ignore-src -r -y # 解决依赖 ``` 3. **编译与验证** ```bash catkin_make # 编译整个工作空间 # 验证安装 rospack find amcl # 应返回路径:~/catkin_ws/devel/share/amcl ``` #### 常见问题解决 - **依赖缺失错误**: 使用 `rosdep install --from-paths src --ignore-src -r -y` 自动安装缺失依赖。 - **CMake 错误**: 确保已安装构建工具: ```bash sudo apt install build-essential cmake ``` - **Python 3 兼容性**: Noetic 默认使用 Python 3,若遇语法错误需检查脚本的 Python 版本兼容性。 #### 验证导航功能 ```bash roslaunch turtlebot3_navigation turtlebot3_navigation.launch # 需先安装 TurtleBot3 模拟包 ``` 若成功启动 RViz 界面并显示地图/传感器数据,则导航功能编译成功[^1]。 ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wuweijie@apache.org

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值