ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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/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.

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).

EDIT:

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)

and

find_package(Boost)

I did find gtest in this conditional, however:

if(CATKIN_ENABLE_TESTING)
  find_package(rostest)
  # Unit test uses gtest, but needs rostest to create a ROS environment.
  # Hence ...
(more)
edit retag flag offensive close merge delete

Comments

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
0

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.

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

Question Tools

1 follower

Stats

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

Seen: 757 times

Last updated: Dec 19 '19