Search code examples
opencvcmakeros

error "No rule to make target ..."when build opencv program ,and "undefined reference to" error


I want to build my simple OpenCV program,but when I build the project,it failed and the error description is:

No rule to make target `/usr/lib/x86_64-linux-gnu/libconsole_bridge.so,opencv_videostab', needed by `/home/turtlebot/catkin_ws/devel/lib/multi_robot_slam/imageConverter'. Stop.

Here is my CmakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(robot_slam)

find_package(catkin REQUIRED
  COMPONENTS
    cmake_modules
    roscpp
    sensor_msgs
    cv_bridge
    std_msgs
    image_transport
)
find_package(OpenCV REQUIRED)

include_directories(include ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})

catkin_package()

add_executable(imageConverter src/imageConverter.cpp)
target_link_libraries(imageConverter ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})

Does anybody know what the problem is and how to solve it?


Solution

  • I finally solved my problem by modified the comma to space.From it i learned that:

    No rule to make target /usr/lib/x86_64linux-gnu/libconsole_bridge.so,opencv_videostab', needed by /home/turtlebot/catkin_ws/devel/lib/multi_robot_slam/imageConverter'.Stop.   
    

    means that someone incorrectly enumerate libraries via comma instead of space.

    And besides,I also solved the problem of

    undefined reference to ***.
    

    These problem usually means absence of the library, or there are more than one version lib on your computer.For me ,it is because the #include<> used the header files of opencv3.2 while the lib used of opencv2.4.So I modified find_package(OpenCV REQUIRED) to find_package(OpenCV 3 REQUIRED) to make lib used is also opencv3.2.And then all problems disappeard and everything goes right!