"No rule to make target" 已经存在
"No rule to make target" which already exists
我正在尝试从源代码构建 ROS,在我没有 root 访问权限的环境中,所以没有 sudo apt-get
。
rospack
需要 libtinyxml-dev
,但我不能只安装那个包。因此,我从源代码构建了 TinyXML,并将其安装到 ~/usr/local/{lib, include}
。一些目标(例如 xmlrpcpp
、rosbuild
)构建良好,但 rospack
抛出
make[2]: *** No rule to make target '/home/USERNAME/usr/local/lib/libtinyxml.so', needed by
'/home/USERNAME/ros_desktop/catkin_ws/devel/.private/rospack/lib/librospack.so'. Stop.
但是,文件 libtinyxml.so
已经存在并且是 libtinyxml.so.2.6.2
的符号链接,后者也存在。我完全不知道该怎么办。我试过 add_library(... SHARED IMPORTED)
,通常是摆弄 CMakeLists.txt
,但没有骰子。我怎样才能告诉 CMake "hey, this library exists, just link against it!" 或者,如果错误实际上意味着别的东西,得到一个信息更丰富的错误?如果图书馆已经存在,为什么还要 make
呢?感谢任何能帮助我的人!
CMakeLists.txt
的内容:
cmake_minimum_required(VERSION 2.8.3)
project(rospack)
find_package(catkin REQUIRED COMPONENTS cmake_modules)
find_package(Boost REQUIRED COMPONENTS filesystem program_options system)
set(Python_ADDITIONAL_VERSIONS "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
find_package(PythonLibs "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" REQUIRED)
find_package(TinyXML REQUIRED)
catkin_package(
INCLUDE_DIRS include
LIBRARIES rospack ${PYTHON_LIBRARIES}
DEPENDS Boost TinyXML
)
#add_definitions(-Wall)
set(API_BACKCOMPAT_V1 "YES" CACHE BOOL "Whether to enable backwards compatibility with old C++ API")
if(API_BACKCOMPAT_V1)
add_definitions(-DROSPACK_API_BACKCOMPAT_V1)
set(backcompat_source src/rospack_backcompat.cpp)
endif()
include_directories(include ${TinyXML_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
add_library(rospack
src/rospack.cpp
${backcompat_source}
src/rospack_cmdline.cpp
src/utils.cpp
)
target_link_libraries(rospack ${TinyXML_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
add_executable(rospackexe src/rospack_main.cpp)
# Set the name, and make it a "global" executable
set_target_properties(rospackexe PROPERTIES
OUTPUT_NAME rospack
RUNTIME_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/bin)
target_link_libraries(rospackexe rospack ${Boost_LIBRARIES})
add_executable(rosstackexe src/rosstack_main.cpp)
target_link_libraries(rosstackexe rospack ${Boost_LIBRARIES})
# Set the name, and make it a "global" executable
set_target_properties(rosstackexe PROPERTIES
OUTPUT_NAME rosstack
RUNTIME_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/bin)
install(TARGETS rospack rospackexe rosstackexe
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h")
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
if(CATKIN_ENABLE_TESTING)
add_subdirectory(test)
endif()
if(DOXYGEN_FOUND)
add_custom_target(rospack-docs
COMMAND doxygen Doxyfile
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
endif()
已解决。
- 克隆 git 存储库中的所有内容,分支
kinetic-devel
- 从 https://github.com/leethomason/tinyxml2.git
克隆 TinyXML2
- 构建 TinyXML2
cd [TinyXML2 DIR]
mkdir build
cd !$
cmake -DCMAKE_INSTALL_PREFIX=$HOME/.local ..
cmake --build .
cmake --build . --target install
- 符号链接 TinyXML2 的 CMake 配置,以便 rospack 可以使用正确的包名称找到
cd $HOME/.local/lib64/cmake/tinyxml2
ln -s tinyxml2Config.cmake TinyXML2Config.cmake
- 像这样修补
rospack
的 CMakeLists.txt
@@ -4 +4 @@
-find_package(catkin REQUIRED COMPONENTS cmake_modules)
+find_package(catkin REQUIRED)
@@ -32 +32 @@
-target_link_libraries(rospack ${TinyXML2_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
+target_link_libraries(rospack tinyxml2::tinyxml2 ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
- 应用 these changes 因为
kinetic-devel
分支不针对 TinyXML2 构建。
catkin build --cmake-args -DCMAKE_PREFIX_PATH=$HOME/.local -- rospack
source [Catkin_Workspace]/devel/setup.bash && catkin build
我正在尝试从源代码构建 ROS,在我没有 root 访问权限的环境中,所以没有 sudo apt-get
。
rospack
需要 libtinyxml-dev
,但我不能只安装那个包。因此,我从源代码构建了 TinyXML,并将其安装到 ~/usr/local/{lib, include}
。一些目标(例如 xmlrpcpp
、rosbuild
)构建良好,但 rospack
抛出
make[2]: *** No rule to make target '/home/USERNAME/usr/local/lib/libtinyxml.so', needed by
'/home/USERNAME/ros_desktop/catkin_ws/devel/.private/rospack/lib/librospack.so'. Stop.
但是,文件 libtinyxml.so
已经存在并且是 libtinyxml.so.2.6.2
的符号链接,后者也存在。我完全不知道该怎么办。我试过 add_library(... SHARED IMPORTED)
,通常是摆弄 CMakeLists.txt
,但没有骰子。我怎样才能告诉 CMake "hey, this library exists, just link against it!" 或者,如果错误实际上意味着别的东西,得到一个信息更丰富的错误?如果图书馆已经存在,为什么还要 make
呢?感谢任何能帮助我的人!
CMakeLists.txt
的内容:
cmake_minimum_required(VERSION 2.8.3)
project(rospack)
find_package(catkin REQUIRED COMPONENTS cmake_modules)
find_package(Boost REQUIRED COMPONENTS filesystem program_options system)
set(Python_ADDITIONAL_VERSIONS "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
find_package(PythonLibs "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" REQUIRED)
find_package(TinyXML REQUIRED)
catkin_package(
INCLUDE_DIRS include
LIBRARIES rospack ${PYTHON_LIBRARIES}
DEPENDS Boost TinyXML
)
#add_definitions(-Wall)
set(API_BACKCOMPAT_V1 "YES" CACHE BOOL "Whether to enable backwards compatibility with old C++ API")
if(API_BACKCOMPAT_V1)
add_definitions(-DROSPACK_API_BACKCOMPAT_V1)
set(backcompat_source src/rospack_backcompat.cpp)
endif()
include_directories(include ${TinyXML_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
add_library(rospack
src/rospack.cpp
${backcompat_source}
src/rospack_cmdline.cpp
src/utils.cpp
)
target_link_libraries(rospack ${TinyXML_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
add_executable(rospackexe src/rospack_main.cpp)
# Set the name, and make it a "global" executable
set_target_properties(rospackexe PROPERTIES
OUTPUT_NAME rospack
RUNTIME_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/bin)
target_link_libraries(rospackexe rospack ${Boost_LIBRARIES})
add_executable(rosstackexe src/rosstack_main.cpp)
target_link_libraries(rosstackexe rospack ${Boost_LIBRARIES})
# Set the name, and make it a "global" executable
set_target_properties(rosstackexe PROPERTIES
OUTPUT_NAME rosstack
RUNTIME_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/bin)
install(TARGETS rospack rospackexe rosstackexe
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h")
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
if(CATKIN_ENABLE_TESTING)
add_subdirectory(test)
endif()
if(DOXYGEN_FOUND)
add_custom_target(rospack-docs
COMMAND doxygen Doxyfile
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
endif()
已解决。
- 克隆 git 存储库中的所有内容,分支
kinetic-devel
- 从 https://github.com/leethomason/tinyxml2.git 克隆 TinyXML2
- 构建 TinyXML2
cd [TinyXML2 DIR]
mkdir build
cd !$
cmake -DCMAKE_INSTALL_PREFIX=$HOME/.local ..
cmake --build .
cmake --build . --target install
- 符号链接 TinyXML2 的 CMake 配置,以便 rospack 可以使用正确的包名称找到
cd $HOME/.local/lib64/cmake/tinyxml2
ln -s tinyxml2Config.cmake TinyXML2Config.cmake
- 像这样修补
rospack
的CMakeLists.txt
@@ -4 +4 @@
-find_package(catkin REQUIRED COMPONENTS cmake_modules)
+find_package(catkin REQUIRED)
@@ -32 +32 @@
-target_link_libraries(rospack ${TinyXML2_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
+target_link_libraries(rospack tinyxml2::tinyxml2 ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
- 应用 these changes 因为
kinetic-devel
分支不针对 TinyXML2 构建。 catkin build --cmake-args -DCMAKE_PREFIX_PATH=$HOME/.local -- rospack
source [Catkin_Workspace]/devel/setup.bash && catkin build