"CMake Error: CMake can not determine linker language for target" The errors appeared when I catkin_make a ROS working space
"CMake Error: CMake can not determine linker language for target" The errors appeared when I catkin_make a ROS working space
当我 catkin_make 我的 ROS 工作 space 时,它总是因错误而结束:
CMake Error: CMake can not determine linker language for target: XX
CMake Error: Cannot determine link language for target "XX".
根据XX的信息,我发现错误可能出在某个ROS包中。包里有一个CMakeList.txt和一个package.xml。 但是我一直不知道是什么原因导致的错误,直到现在我也没有解决这个问题。下面我给出了两个文件的确切代码。
CMakeList.txt
cmake_minimum_required(VERSION 3.0.2)
project(omnicopter_controller)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS
geometry_msgs
mav_msgs
nav_msgs
sensor_msgs
cmake_modules
roscpp
rospy
std_msgs
)
find_package(Eigen3 REQUIRED)
catkin_package(
INCLUDE_DIRS include ${Eigen3_INCLUDE_DIRS}
LIBRARIES omnicopter_controller
CATKIN_DEPENDS geometry_msgs mav_msgs nav_msgs roscpp sensor_msgs
DEPENDS Eigen3
)
include_directories(
include
${catkin_INCLUDE_DIRS}
${Eigen3_INCLUDE_DIRS}
)
add_executable(omnicopter_position_controller_pub
src/omnicopter_position_controller_pub.cpp
)
add_dependencies(omnicopter_position_controller_pub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_position_controller_pub
${catkin_LIBRARIES}
)
add_executable(omnicopter_position_controller_sub
src/omnicopter_position_controller_sub.cpp
)
add_dependencies(omnicopter_position_controller_sub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_position_controller_sub
${catkin_LIBRARIES}
)
add_executable(omnicopter_attitude_controller_pub
src/omnicopter_attitude_controller_pub.cpp
)
add_dependencies(omnicopter_attitude_controller_pub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_attitude_controller_pub
${catkin_LIBRARIES}
)
add_executable(omnicopter_attitude_controller_sub
src/omnicopter_attitude_controller_sub.cpp
)
add_dependencies(omnicopter_attitude_controller_sub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_attitude_controller_sub
${catkin_LIBRARIES}
)
add_executable(omnicopter_body_angular_velocity_controller_pub
src/omnicopter_body_angular_velocity_controller_pub.cpp
)
add_dependencies(omnicopter_body_angular_velocity_controller_pub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_body_angular_velocity_controller_pub
${catkin_LIBRARIES}
)
add_executable(omnicopter_body_angular_velocity_controller_sub
src/omnicopter_body_angular_velocity_controller_sub.cpp
)
add_dependencies(omnicopter_body_angular_velocity_controller_sub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_body_angular_velocity_controller_sub
${catkin_LIBRARIES}
)
add_executable(omnicopter_control_allocator_pub
src/omnicopter_control_allocator_pub.cpp
)
add_dependencies(omnicopter_control_allocator_pub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_control_allocator_pub
${catkin_LIBRARIES}
)
add_executable(omnicopter_control_allocator_sub
src/omnicopter_control_allocator_sub.cpp
)
add_dependencies(omnicopter_control_allocator_sub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_control_allocator_sub
${catkin_LIBRARIES}
)
add_library(omnicopter_position_controller
include/omnicopter_controller/omnicopter_position_controller.h
)
add_dependencies(omnicopter_position_controller ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_position_controller
${catkin_LIBRARIES}
)
add_library(omnicopter_attitude_controller
include/omnicopter_controller/omnicopter_attitude_controller.h
)
add_dependencies(omnicopter_attitude_controller ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_attitude_controller
${catkin_LIBRARIES}
)
add_library(omnicopter_body_angular_velocity_controller
include/omnicopter_controller/omnicopter_body_angular_velocity_controller.h
)
add_dependencies(omnicopter_body_angular_velocity_controller ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_body_angular_velocity_controller
${catkin_LIBRARIES}
)
add_library(omnicopter_control_allocator
include/omnicopter_controller/omnicopter_control_allocator.h
)
add_dependencies(omnicopter_control_allocator ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_control_allocator
${catkin_LIBRARIES}
)
package.xml
<?xml version="1.0"?>
<package format="2">
<name>omnicopter_controller</name>
<version>0.0.0</version>
<description>The omnicopter_controller package</description>
<maintainer email="hdl@todo.todo">hdl</maintainer>
<author>Dingliang Huang</author>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<depend>rospy</depend>
<depend>std_msgs</depend>
<depend>cmake_modules</depend>
<depend>dynamic_reconfigure</depend>
<depend>geometry_msgs</depend>
<depend>mav_msgs</depend>
<depend>nav_msgs</depend>
<depend>roscpp</depend>
<depend>sensor_msgs</depend>
</package>
下面我显示了确切的错误。
错误:
CMake Error: CMake can not determine linker language for target: omnicopter_position_controller
CMake Error: Cannot determine link language for target "omnicopter_position_controller".
CMake Error: CMake can not determine linker language for target: omnicopter_attitude_controller
CMake Error: Cannot determine link language for target "omnicopter_attitude_controller".
CMake Error: CMake can not determine linker language for target: omnicopter_control_allocator
CMake Error: Cannot determine link language for target "omnicopter_control_allocator".
CMake Error: CMake can not determine linker language for target: omnicopter_body_angular_velocity_controller
CMake Error: Cannot determine link language for target "omnicopter_body_angular_velocity_controller".
我希望有人能帮我解决这些错误。我将不胜感激。
我已经解决了问题。这些错误是由于在每个 add_library() 之后缺少 set_target_properties(XX PROPERTIES LINKER_LANGUAGE C++) 造成的。
当我 catkin_make 我的 ROS 工作 space 时,它总是因错误而结束:
CMake Error: CMake can not determine linker language for target: XX
CMake Error: Cannot determine link language for target "XX".
根据XX的信息,我发现错误可能出在某个ROS包中。包里有一个CMakeList.txt和一个package.xml。 但是我一直不知道是什么原因导致的错误,直到现在我也没有解决这个问题。下面我给出了两个文件的确切代码。
CMakeList.txt
cmake_minimum_required(VERSION 3.0.2)
project(omnicopter_controller)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS
geometry_msgs
mav_msgs
nav_msgs
sensor_msgs
cmake_modules
roscpp
rospy
std_msgs
)
find_package(Eigen3 REQUIRED)
catkin_package(
INCLUDE_DIRS include ${Eigen3_INCLUDE_DIRS}
LIBRARIES omnicopter_controller
CATKIN_DEPENDS geometry_msgs mav_msgs nav_msgs roscpp sensor_msgs
DEPENDS Eigen3
)
include_directories(
include
${catkin_INCLUDE_DIRS}
${Eigen3_INCLUDE_DIRS}
)
add_executable(omnicopter_position_controller_pub
src/omnicopter_position_controller_pub.cpp
)
add_dependencies(omnicopter_position_controller_pub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_position_controller_pub
${catkin_LIBRARIES}
)
add_executable(omnicopter_position_controller_sub
src/omnicopter_position_controller_sub.cpp
)
add_dependencies(omnicopter_position_controller_sub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_position_controller_sub
${catkin_LIBRARIES}
)
add_executable(omnicopter_attitude_controller_pub
src/omnicopter_attitude_controller_pub.cpp
)
add_dependencies(omnicopter_attitude_controller_pub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_attitude_controller_pub
${catkin_LIBRARIES}
)
add_executable(omnicopter_attitude_controller_sub
src/omnicopter_attitude_controller_sub.cpp
)
add_dependencies(omnicopter_attitude_controller_sub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_attitude_controller_sub
${catkin_LIBRARIES}
)
add_executable(omnicopter_body_angular_velocity_controller_pub
src/omnicopter_body_angular_velocity_controller_pub.cpp
)
add_dependencies(omnicopter_body_angular_velocity_controller_pub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_body_angular_velocity_controller_pub
${catkin_LIBRARIES}
)
add_executable(omnicopter_body_angular_velocity_controller_sub
src/omnicopter_body_angular_velocity_controller_sub.cpp
)
add_dependencies(omnicopter_body_angular_velocity_controller_sub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_body_angular_velocity_controller_sub
${catkin_LIBRARIES}
)
add_executable(omnicopter_control_allocator_pub
src/omnicopter_control_allocator_pub.cpp
)
add_dependencies(omnicopter_control_allocator_pub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_control_allocator_pub
${catkin_LIBRARIES}
)
add_executable(omnicopter_control_allocator_sub
src/omnicopter_control_allocator_sub.cpp
)
add_dependencies(omnicopter_control_allocator_sub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_control_allocator_sub
${catkin_LIBRARIES}
)
add_library(omnicopter_position_controller
include/omnicopter_controller/omnicopter_position_controller.h
)
add_dependencies(omnicopter_position_controller ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_position_controller
${catkin_LIBRARIES}
)
add_library(omnicopter_attitude_controller
include/omnicopter_controller/omnicopter_attitude_controller.h
)
add_dependencies(omnicopter_attitude_controller ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_attitude_controller
${catkin_LIBRARIES}
)
add_library(omnicopter_body_angular_velocity_controller
include/omnicopter_controller/omnicopter_body_angular_velocity_controller.h
)
add_dependencies(omnicopter_body_angular_velocity_controller ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_body_angular_velocity_controller
${catkin_LIBRARIES}
)
add_library(omnicopter_control_allocator
include/omnicopter_controller/omnicopter_control_allocator.h
)
add_dependencies(omnicopter_control_allocator ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(omnicopter_control_allocator
${catkin_LIBRARIES}
)
package.xml
<?xml version="1.0"?>
<package format="2">
<name>omnicopter_controller</name>
<version>0.0.0</version>
<description>The omnicopter_controller package</description>
<maintainer email="hdl@todo.todo">hdl</maintainer>
<author>Dingliang Huang</author>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<depend>rospy</depend>
<depend>std_msgs</depend>
<depend>cmake_modules</depend>
<depend>dynamic_reconfigure</depend>
<depend>geometry_msgs</depend>
<depend>mav_msgs</depend>
<depend>nav_msgs</depend>
<depend>roscpp</depend>
<depend>sensor_msgs</depend>
</package>
下面我显示了确切的错误。
错误:
CMake Error: CMake can not determine linker language for target: omnicopter_position_controller
CMake Error: Cannot determine link language for target "omnicopter_position_controller".
CMake Error: CMake can not determine linker language for target: omnicopter_attitude_controller
CMake Error: Cannot determine link language for target "omnicopter_attitude_controller".
CMake Error: CMake can not determine linker language for target: omnicopter_control_allocator
CMake Error: Cannot determine link language for target "omnicopter_control_allocator".
CMake Error: CMake can not determine linker language for target: omnicopter_body_angular_velocity_controller
CMake Error: Cannot determine link language for target "omnicopter_body_angular_velocity_controller".
我希望有人能帮我解决这些错误。我将不胜感激。
我已经解决了问题。这些错误是由于在每个 add_library() 之后缺少 set_target_properties(XX PROPERTIES LINKER_LANGUAGE C++) 造成的。