at hello_vscode/CMakeLists.txt:150 (target_link_libraries): Target "subscriber" of type EXECUTABLE may not be linked into another target. One may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to executables with the ENABLE_EXPORTS property set.
时间: 2024-03-30 16:34:12 浏览: 158
这个错误是因为在 CMakeLists.txt 文件的第 150 行,你正在尝试将一个类型为 EXECUTABLE 的目标 "subscriber" 链接到另一个目标中。这是不被允许的,因为 EXECUTABLE 类型的目标只能被链接到 INTERFACE、OBJECT、STATIC 或 SHARED 库,或者具有 ENABLE_EXPORTS 属性设置的可执行文件中。
你可以尝试将目标 "subscriber" 更改为一个库类型的目标,或者使用 ENABLE_EXPORTS 属性来允许将它链接到其他目标中。具体如何修改取决于你的项目需求和目标结构。
相关问题
ubuntu16.04运行时报错CMake Error at bobac2_description/CMakeLists.txt:147 (add_dependencies): Cannot add target-level dependencies to non-existent target "bobac2_description_node". The add_dependencies works for top-level logical targets created by the add_executable, add_library, or add_custom_target commands. If you want to add file-level dependencies see the DEPENDS option of the add_custom_target and add_custom_command commands. CMake Error at bobac2_description/CMakeLists.txt:150 (target_link_libraries): Cannot specify link libraries for target "bobac2_description_node" which is not built by this project. -- Configuring incomplete, errors occurred! See also "/home/bobac3/ros_workspace/build/CMakeFiles/CMakeOutput.log". See also "/home/bobac3/ros_workspace/build/CMakeFiles/CMakeError.log". Makefile:2796: recipe for target 'cmake_check_build_system' failed make: *** [cmake_check_build_system] Error 1 CMake Error at bobac2_description/CMakeLists.txt:147 (add_dependencies): Cannot add target-level dependencies to non-existent target "bobac2_description_node". The add_dependencies works for top-level logical targets created by the add_executable, add_library, or add_custom_target commands. If you want to add file-level dependencies see the DEPENDS option of the add_custom_target and add_custom_command commands. CMake Error at bobac2_description/CMakeLists.txt:150 (target_link_libraries): Cannot specify link libraries for target "bobac2_description_node" which is not built by this project. -- Configuring incomplete, errors occurred! See also "/home/bobac3/ros_workspace/build/CMakeFiles/CMakeOutput.log". See also "/home/bobac3/ros_workspace/build/CMakeFiles/CMakeError.log". Makefile:2796: recipe for target 'cmake_check_build_system' failed make: *** [cmake_check_build_system] Error 1
这个错误可能是因为在运行CMake时,找不到名为"bobac2_description_node"的目标。这可能是因为在CMakeLists.txt文件中没有正确地定义目标或源文件。您可以检查一下CMakeLists.txt文件中的目标和源文件是否正确定义。另外,您可以尝试清理并重新构建项目,以确保没有编译错误。您也可以查看CMakeError.log和CMakeOutput.log文件,以获取更多关于错误的详细信息。
CMake Error at data-plane/suricata-3.0/src/CMakeLists.txt:548 (TARGET_LINK_LIBRARIES): The keyword signature for target_link_libraries has already been used with the target "dp". All uses of target_link_libraries with a target must be either all-keyword or all-plain. The uses of the keyword signature are here: * data-plane/suricata-3.0/src/CMakeLists.txt:542 (TARGET_LINK_LIBRARIES)
这个错误是由于同一个目标 "dp" 在 CMakeLists.txt 文件的不同位置使用了不同的 target_link_libraries 形式。在这种情况下,你需要确保在该文件中所有使用 "dp" 的 target_link_libraries 调用都采用相同的语法形式,要么全部使用关键字形式,要么全部使用普通形式。
在你的情况中,可以查看 CMakeLists.txt 文件中第 542 行和第 548 行的 target_link_libraries 调用,并确保它们采用相同的语法形式。如果它们是不同的,则需要进行更改以使其匹配。例如,如果第 542 行使用了关键字形式,则第 548 行也应该使用关键字形式。
阅读全文