I am trying to create a coverage report for my gtest unit test cases, but I am facing this error at the end of compilation.
error:
/usr/bin/ld: gtest_hinoDevelop: hidden symbol `__gcov_exit' in /usr/lib/gcc/x86_64-linux-gnu/9/libgcov.a(_gcov.o) is referenced by DSO
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
My CMakeLists.txt:
cmake_minimum_required(VERSION 3.0.2)
project(hino_develop)
add_compile_options(-fprofile-arcs -ftest-coverage)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
laser_geometry
pcl_conversions
pcl_ros
std_msgs
message_filters
cv_bridge
tf
tf_conversions
eigen_conversions
image_transport
)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
find_package(PCL REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Eigen3 REQUIRED)
set(HINO_LIDAR_REL_PATH "../src/hino_develop/")
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
# include
${catkin_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/include
${HINO_LIDAR_REL_PATH}/include
)
set(gtest_LIB_DIR "../ExternalLib/")
link_directories(${gtest_LIB_DIR})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
target_link_libraries(gtest_hinoDevelop ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${Boost_LIBRARIES} ${OpenCV_INCLUDE_DIRS})
target_link_libraries(gtest_hinoDevelop yaml-cpp)
target_link_libraries(gtest_hinoDevelop gtest)
target_link_libraries(gtest_hinoDevelop gcov)
target_include_directories(gtest_hinoDevelop PUBLIC "/include")
When I have tried it with my source code, I am able to create the coverage report, So I used the same method with my testing code but I am stuck with this error. What am I missing?