ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

GTest compile error during workspace build

asked 2019-12-19 11:38:52 -0500

Joey Tan gravatar image

updated 2019-12-19 12:47:50 -0500

Trying to build my workspace using

sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic

but I keep getting the following error while it's building camera_info_manager:

==> Processing catkin package: 'camera_info_manager'
==> Building with env: '/opt/ros/kinetic/'
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/
[ 50%] Built target camera_info_manager
In file included from /usr/src/gtest/src/
/usr/src/gtest/src/ In destructor ‘virtual testing::Test::~Test()’:
/usr/src/gtest/src/ 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/ At global scope:
/usr/src/gtest/src/ 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/
/usr/local/include/gtest/gtest.h:772:3: error: candidates are: testing::TestInfo::TestInfo(const testing::TestInfo&)
In file included from /usr/src/gtest/src/
/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/' failed
make[2]: *** [gtest/gtest/CMakeFiles/gtest.dir/src/] 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/', '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/ make -j4 -l4

Command failed, exiting.

What is strange to me is that it looks like the problems are all contained within gtest. I can't find anything relevant, but I tried installing gtest from source as opposed to from the binaries and it still had no change (even with compiling with C++11).


In camera_info_manager's CMakeLists.txt, gtest isn't in the two first find_package calls:

find_package(catkin REQUIRED COMPONENTS camera_calibration_parsers image_transport roscpp roslib sensor_msgs)



I did find gtest in this conditional, however:

  # Unit test uses gtest, but needs rostest to create a ROS environment.
  # Hence ...
edit retag flag offensive close merge delete


Could you please add the find_package sections of your CMakeLists.txt?

ct2034 gravatar image ct2034  ( 2019-12-19 12:40:21 -0500 )edit

@ct2034 It's done; gtest is only mentioned in a conditional statement block though. Would it be as simple as disabling that? EDIT: apparently it is that simple. It has compiled through without problem.

Joey Tan gravatar image Joey Tan  ( 2019-12-19 12:48:44 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2019-12-19 13:07:32 -0500

Joey Tan gravatar image

Commenting out this block of code (or deleting it) in camera_info_manager's CMakeLists.txt allows the package to compile without including gtest, though I'm assuming this disables testing for this package and I'm unaware of any consequences that can arise from that.

  # 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})
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-12-19 11:38:52 -0500

Seen: 663 times

Last updated: Dec 19 '19