我正在尝试编译 catkin 工作区,但不断收到此错误消息(或消息)。在此处以及 ROS Answers 中发布,因为看起来错误包含在 gtest 中,而不是 ROS 包中。
到目前为止我已经尝试过:
- 从源代码构建和安装 gtest
和
- 使用 C++11 构建包
两次都产生了相同的错误信息。在网上,我找不到任何能解决这个问题的人。
尝试使用构建我的工作区
sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic
但是在构建 camera_info_manager 时我一直收到以下错误:
==> Processing catkin package: 'camera_info_manager'
==> Building with env: '/opt/ros/kinetic/env.sh'
Makefile exists, skipping explicit cmake invocation...
==> make cmake_check_build_system in '/home/pi/catkin_ws/build_isolated/camera_info_manager'
==> make -j4 -l4 in '/home/pi/catkin_ws/build_isolated/camera_info_manager'
[ 16%] Building CXX object gtest/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 50%] Built target camera_info_manager
In file included from /usr/src/gtest/src/gtest-all.cc:42:0:
/usr/src/gtest/src/gtest.cc: In destructor ‘virtual testing::Test::~Test()’:
/usr/src/gtest/src/gtest.cc:1897:10: error: type ‘const class testing::internal::scoped_ptr<testing::internal::GTestFlagSaver>’ argument given to ‘delete’, expected pointer
delete gtest_flag_saver_;
^
/usr/src/gtest/src/gtest.cc: At global scope:
/usr/src/gtest/src/gtest.cc:2177:1: error: prototype for ‘testing::TestInfo::TestInfo(const string&, const string&, const char*, const char*, testing::internal::TypeId, testing::internal::TestFactoryBase*)’ does not match any in class ‘testing::TestInfo’
TestInfo::TestInfo(const std::string& a_test_case_name,
^
In file included from /usr/local/include/gtest/internal/gtest-internal.h:40:0,
from /usr/local/include/gtest/gtest.h:58,
from /usr/src/gtest/src/gtest-all.cc:39:
/usr/local/include/gtest/gtest.h:772:3: error: candidates are: testing::TestInfo::TestInfo(const testing::TestInfo&)
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
^
In file included from /usr/src/gtest/src/gtest-all.cc:39:0:
/usr/local/include/gtest/gtest.h:728:3: error: testing::TestInfo::TestInfo(const string&, const string&, const char*, const char*, testing::internal::CodeLocation, testing::internal::TypeId, testing::internal::TestFactoryBase*)
TestInfo(const std::string& test_case_name,
^
//------------------------------------------------------------------
// and a lot more of similar syntax-related issues
//------------------------------------------------------------------
gtest/gtest/CMakeFiles/gtest.dir/build.make:62: recipe for target 'gtest/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o' failed
make[2]: *** [gtest/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o] Error 1
CMakeFiles/Makefile2:1463: recipe for target 'gtest/gtest/CMakeFiles/gtest.dir/all' failed
make[1]: *** [gtest/gtest/CMakeFiles/gtest.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
<== Failed to process package 'camera_info_manager':
Command '['/opt/ros/kinetic/env.sh', 'make', '-j4', '-l4']' returned non-zero exit status 2
Reproduce this error by running:
==> cd /home/pi/catkin_ws/build_isolated/camera_info_manager && /opt/ros/kinetic/env.sh make -j4 -l4
Command failed, exiting.
答案1
注释掉
if(CATKIN_ENABLE_TESTING)
find_package(rostest)
# Unit test uses gtest, but needs rostest to create a ROS environment.
# Hence, it must be created as a normal executable, not using
# catkin_add_gtest() which runs an additional test without rostest.
add_executable(unit_test tests/unit_test.cpp)
target_link_libraries(unit_test ${PROJECT_NAME} ${GTEST_LIBRARIES} ${catkin_LIBRARIES})
在 camera_info_manager 的 CMakeLists.txt 中。据我所知,这只会禁用包的单元测试,但我基本不知道这样做的后果。