Ask Your Question
1

No rule to make target for gTest

asked 2014-12-09 13:49:01 -0500

kunaltyagi gravatar image

updated 2014-12-11 05:41:40 -0500

While using $ catkin_make run_tests_test_pkg, the following error is generated by cmake:

*** No rule to make target '/usr/lib/libgtest.so', needed by '/home/username/catkin_ws/devel/lib/test_pkg/sampleTest'. Stop.

I uninstalled gtest (and ROS) and reinstalled it again, but the error persists. The tests are successfully built on another system (ensured via git) with same OS (ubuntu 14.04)

What are the possible reasons for this error, and how can this be removed?

EDIT: CMakeLists.txt (unchanged, except for minor filename modifications:

cmake_minimum_required(VERSION 2.8.3)
project(my_library)

find_package(catkin REQUIRED COMPONENTS my_msgs geometry_msgs roscpp roslib sensor_msgs std_msgs actionlib actionlib_msgs)

catkin_package(
  INCLUDE_DIRS include
  CATKIN_DEPENDS my_msgs geometry_msgs roscpp roslib sensor_msgs std_msgs actionlib actionlib_msgs
)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -fprofile-arcs -ftest-coverage")

include_directories(
  include/
  ${catkin_INCLUDE_DIRS}
)

set(math_HDRS
    include/my_library/math/abc.h
    include/my_library/math/xyz.h
)

set(math_SRCS
    src/math/xyz.cpp
)

set(math_test_HDRS
    ${math_HDRS}
    include/my_library/math/abc_test.h
    include/my_library/math/xyz_test.h
)

set(math_test_SRCS
    ${math_SRCS}
    src/math/main_test.cpp
)

add_library(my_library ${actionlib_HDRS} ${actionlib_SRCS} ${math_HDRS} ${math_SRCS})  # ${param_HDRS}     ${param_SRCS})
add_dependencies(my_library ${catkin_EXPORTED_TARGETS})
target_link_libraries(my_library ${catkin_LIBRARIES} ${Boost_LIBRARIES} yaml-cpp)
set(CMAKE_C++_CREATE_SHARED_LIBRARY)
SET_TARGET_PROPERTIES(my_library PROPERTIES LINKER_LANGUAGE CXX)

catkin_add_gtest(math_test ${math_test_SRCS} ${math_test_HDRS})

EDIT: clean cmake output (removed mangled c++ function names, and repetition of errors):

Base path: /home/kunaltyagi/catkin_ws
Source space: /home/kunaltyagi/catkin_ws/src
Build space: /home/kunaltyagi/catkin_ws/build
Devel space: /home/kunaltyagi/catkin_ws/devel
Install space: /home/kunaltyagi/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/kunaltyagi/catkin_ws/build"
####
####
#### Running command: "make run_tests_my_library -j8 -l8" in "/home/kunaltyagi/catkin_ws/build"
####
Scanning dependencies of target math_test
[100%] Building CXX object my_library/CMakeFiles/math_test.dir/src/math/main_test.cpp.o
Linking CXX executable /home/kunaltyagi/catkin_ws/devel/lib/my_library/math_test
CMakeFiles/math_test.dir/src/math/main_test.cpp.o:(txt+0x07): In file /home/kunaltyagi/catkin_ws/my_library/src/math/main_test.cpp
*** No rule to make target '/usr/lib/libgtest.so', needed by '/home/kunaltyagi/catkin_ws/devel/lib/my_library/math_test'. Stop.
CMakeFiles/math_test.dir/src/math/main_test.cpp.o:(txt+0xc1): In function 'testing::internal::FormatForComparisonFailureMessage(char const*, std::string const&)':
/usr/include/gtest/gtest.h:1328: error: undefined reference to 'testing::internal::EqFailure(char const, char const, testing::internal::String const&, testing::internal::String const&, bool)'
**** repeat this multiple times for each usage of ASSERT_EQ and EXPECT_EQ****
/usr/include/gtest/gtest.h:1328: error: undefined reference to 'testing::internal::EqFailure(char const, char const, testing::internal::String const&, testing::internal::String const&, bool)'
collect2: error: ld returned 1 exit status
make[3]: *** [my_library/CMakeFiles/math_test.dir/src/math/main_test.cpp.o] Error 1
make[2]: *** [my_library/CMakeFiles/math_test.dir/all] Error 2
make[1]: *** [my_library/CMakeFiles/run_tests_my_library.dir/rule] Error 2
make: *** [run_tests_my_library] Error 2
Invoking "make" failed
edit retag flag offensive close merge delete

Comments

After reinstalling have you deleted the build/CMakeCache.txt file? If not, please do so and try another (clean) build. If it still doesn't work please post the complete output of CMake.

Dirk Thomas gravatar image Dirk Thomas  ( 2014-12-10 13:01:39 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2014-12-09 22:16:09 -0500

ahendrix gravatar image

The troubleshooting here is pretty simple: check that the file in question exists, and maybe check which package owns it on both systems (dpkg -S /usr/lib/libgtest.so).

edit flag offensive delete link more

Comments

dpkg-query: no path found matching pattern /usr/lib/libgtest.so

kunaltyagi gravatar image kunaltyagi  ( 2014-12-10 12:39:17 -0500 )edit
1

gtest does not install a system wide library. It must be build for each project you want to use it.

Dirk Thomas gravatar image Dirk Thomas  ( 2014-12-10 12:59:41 -0500 )edit

@kunaltyagi: I think you missed the first step: check if the file in question exists; preferably on both systems. YOU need to determine how your systems differ.

ahendrix gravatar image ahendrix  ( 2014-12-10 13:08:42 -0500 )edit

@dirk-thomas: in theory, yes. In reality, catkin usually hides that from the user.

ahendrix gravatar image ahendrix  ( 2014-12-10 13:09:52 -0500 )edit

@ahendrix: The output is same on both systems, the file does not exist on both the systems. @dirk-thomas: I know. That's wht I am puzzled. gtest is built per package, by toplevel.cmake, the cmake for gtests is in /opt/ros/<distro>/share/catkin/cmake/test/gtest.cmake for a default installation

kunaltyagi gravatar image kunaltyagi  ( 2014-12-10 13:32:52 -0500 )edit

@kunaltyagi: is it possible that you're missing the cmake call that triggers compilation of gtest, and it happens to work on one machine because you have a package somewhere else in your workspace that is triggering the compilation of gtest for you?

ahendrix gravatar image ahendrix  ( 2014-12-10 13:46:50 -0500 )edit

@kunaltyagi Please post more information: the complete output of a clean build, the CMakeLists.txt of your package etc.

Dirk Thomas gravatar image Dirk Thomas  ( 2014-12-10 13:55:19 -0500 )edit

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

Stats

Asked: 2014-12-09 13:49:01 -0500

Seen: 3,644 times

Last updated: Dec 11 '14