我正在尝试使LSD_SLAM工作,但是以91%的速度运行catkin_make
命令时。我收到错误消息/ usr / bin / ld:
/ usr / bin / ld:找不到-lcsparse
我已经尝试使用此命令sudo ln -s /usr/local/lib/libg2o_solver_csparse.so /usr/bin/lcsparse.so
进行软链接,但这不能解决问题。
这是完整的错误消息:
[ 91%] Linking CXX shared library /home/adas/lsd-slam_workspace/devel/lib/liblsdslam.so
/usr/bin/ld: cannot find -lcsparse
collect2: error: ld returned 1 exit status
lsd_slam/lsd_slam_core/CMakeFiles/lsdslam.dir/build.make:755: recipe for target '/home/adas/lsd-slam_workspace/devel/lib/liblsdslam.so' failed
make[2]: * [/home/adas/lsd-slam_workspace/devel/lib/liblsdslam.so] Error 1 CMakeFiles/Makefile2:2385: recipe for target 'lsd_slam/lsd_slam_core/CMakeFiles/lsdslam.dir/all' failed
make[1]: [lsd_slam/lsd_slam_core/CMakeFiles/lsdslam.dir/all] Error 2 Makefile:140: recipe for target 'all' failed
make: ** [all] Error 2
Invoking "make -j4 -l4" failed
说实话,我不知道我应该尝试其他方法,因为在apt中也没有所谓的lcsparse
。
此外,我还在其他两台计算机上进行了尝试,但由于此错误仍然卡住。
以下是我已安装的一些信息,可能对我有所帮助:
这也是CMakeList.txt
cmake_minimum_required(VERSION 2.8.7)
project(lsd_slam_core)
# Set the build type. Options are:
# Coverage : w/ debug symbols, w/o optimization, w/ code-coverage
# Debug : w/ debug symbols, w/o optimization
# Release : w/o debug symbols, w/ optimization
# RelWithDebInfo : w/ debug symbols, w/ optimization
# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries
set(CMAKE_BUILD_TYPE Release)
find_package(catkin REQUIRED COMPONENTS
cv_bridge
OpenCV
dynamic_reconfigure
sensor_msgs
image_transport
roscpp
rosbag
cmake_modules
lsd_slam_viewer
)
find_package(Eigen3 REQUIRED)
find_package(X11 REQUIRED)
include(cmake/FindG2O.cmake)
include(cmake/FindSuiteParse.cmake)
message("-- CHOLMOD_INCLUDE_DIR : " ${CHOLMOD_INCLUDE_DIR})
message("-- CSPARSE_INCLUDE_DIR : " ${CSPARSE_INCLUDE_DIR})
message("-- G2O_INCLUDE_DIR : " ${G2O_INCLUDE_DIR})
# FabMap
# uncomment this part to enable fabmap
#add_subdirectory(${PROJECT_SOURCE_DIR}/thirdparty/openFabMap)
#include_directories(${PROJECT_SOURCE_DIR}/thirdparty/openFabMap/include)
#add_definitions("-DHAVE_FABMAP")
#set(FABMAP_LIB openFABMAP )
generate_dynamic_reconfigure_options(
cfg/LSDDebugParams.cfg
cfg/LSDParams.cfg
)
catkin_package(
LIBRARIES lsdslam
DEPENDS EIGEN3 SuiteSparse
CATKIN_DEPENDS libg2o
)
# SSE flags
add_definitions("-DUSE_ROS")
add_definitions("-DENABLE_SSE")
# Also add some useful compiler flag
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -march=native -Wall -std=c++0x"
)
# Set source files
set(lsd_SOURCE_FILES
${PROJECT_SOURCE_DIR}/src/DataStructures/Frame.cpp
${PROJECT_SOURCE_DIR}/src/DataStructures/FramePoseStruct.cpp
${PROJECT_SOURCE_DIR}/src/DataStructures/FrameMemory.cpp
${PROJECT_SOURCE_DIR}/src/SlamSystem.cpp
${PROJECT_SOURCE_DIR}/src/LiveSLAMWrapper.cpp
${PROJECT_SOURCE_DIR}/src/DepthEstimation/DepthMap.cpp
${PROJECT_SOURCE_DIR}/src/DepthEstimation/DepthMapPixelHypothesis.cpp
${PROJECT_SOURCE_DIR}/src/util/globalFuncs.cpp
${PROJECT_SOURCE_DIR}/src/util/SophusUtil.cpp
${PROJECT_SOURCE_DIR}/src/util/settings.cpp
${PROJECT_SOURCE_DIR}/src/util/Undistorter.cpp
${PROJECT_SOURCE_DIR}/src/Tracking/Sim3Tracker.cpp
${PROJECT_SOURCE_DIR}/src/Tracking/Relocalizer.cpp
${PROJECT_SOURCE_DIR}/src/Tracking/SE3Tracker.cpp
${PROJECT_SOURCE_DIR}/src/Tracking/TrackingReference.cpp
${PROJECT_SOURCE_DIR}/src/IOWrapper/Timestamp.cpp
${PROJECT_SOURCE_DIR}/src/GlobalMapping/FabMap.cpp
${PROJECT_SOURCE_DIR}/src/GlobalMapping/KeyFrameGraph.cpp
${PROJECT_SOURCE_DIR}/src/GlobalMapping/g2oTypeSim3Sophus.cpp
${PROJECT_SOURCE_DIR}/src/GlobalMapping/TrackableKeyFrameSearch.cpp
)
set(SOURCE_FILES
${lsd_SOURCE_FILES}
${PROJECT_SOURCE_DIR}/src/IOWrapper/ROS/ROSImageStreamThread.cpp
${PROJECT_SOURCE_DIR}/src/IOWrapper/ROS/ROSOutput3DWrapper.cpp
${PROJECT_SOURCE_DIR}/src/IOWrapper/OpenCV/ImageDisplay_OpenCV.cpp
)
include_directories(
include
${EIGEN3_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/thirdparty/Sophus
${CSPARSE_INCLUDE_DIR} #Has been set by SuiteParse
${CHOLMOD_INCLUDE_DIR} #Has been set by SuiteParse
${OpenCV_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
)
# build shared library.
add_library(lsdslam SHARED ${SOURCE_FILES})
target_link_libraries(lsdslam ${FABMAP_LIB} ${G2O_LIBRARIES} ${catkin_LIBRARIES} csparse cxsparse X11)
#rosbuild_link_boost(lsdslam thread)
# build live ros node
add_executable(live_slam src/main_live_odometry.cpp)
target_link_libraries(live_slam lsdslam ${catkin_LIBRARIES} ${G2O_LIBRARIES})
# build image node
add_executable(dataset src/main_on_images.cpp)
add_dependencies(lsdslam lsd_slam_viewer_generate_messages_cpp)
add_dependencies(live_slam lsd_slam_viewer_generate_messages_cpp)
add_dependencies(dataset lsd_slam_viewer_generate_messages_cpp)
target_link_libraries(dataset lsdslam ${catkin_LIBRARIES} ${G2O_LIBRARIES})
target_link_libraries(live_slam lsdslam ${OpenCV_LIBRARIES})
# TODO add INSTALL
或多或少地修复了错误消息的问题...
我将此添加到了CMakeList.txt
find_path(CSPARSE_INCLUDE_DIR NAMES cs.h
PATHS
/usr/include/suitesparse
/usr/include
/opt/local/include
/usr/local/include
/sw/include
/usr/include/ufsparse
/opt/local/include/ufsparse
/usr/local/include/ufsparse
/sw/include/ufsparse
PATH_SUFFIXES
suitesparse
)
,并将csparse
中的cxsparse
和target_linked_libraries
替换为${CSPARSE_INCLUDE_DIR}
。现在,我在***处遇到未定义的引用
看到这里:
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_post«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_etree«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »g2o::csparse_extension::cs_chol_workspace(cs_di_sparse const*, cs_di_symbolic const*, int*, double*)«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_pinv«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_counts«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_sfree«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_spfree«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »g2o::csparse_extension::cs_cholsolsymb(cs_di_sparse const*, double*, cs_di_symbolic const*, double*, int*)«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_nfree«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_amd«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_cumsum«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_symperm«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_schol«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_calloc«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_malloc«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »cs_di_free«
/home/alex/Schreibtisch/workspace/devel/lib/liblsdslam.so: Warnung: undefinierter Verweis auf »g2o::csparse_extension::writeCs2Octave(char const*, cs_di_sparse const*, bool)«
collect2: error: ld returned 1 exit status
lsd_slam/lsd_slam_core/CMakeFiles/live_slam.dir/build.make:232: recipe for target '/home/alex/Schreibtisch/workspace/devel/lib/lsd_slam_core/live_slam' failed
make[2]: *** [/home/alex/Schreibtisch/workspace/devel/lib/lsd_slam_core/live_slam] Error 1
CMakeFiles/Makefile2:2348: recipe for target 'lsd_slam/lsd_slam_core/CMakeFiles/live_slam.dir/all' failed
make[1]: *** [lsd_slam/lsd_slam_core/CMakeFiles/live_slam.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
HERE也是完整的输出。
答案 0 :(得分:0)
好的,我自己修复了。
这是我所做的步骤。
首先,我进行了EDIT 2中介绍的步骤。
之后,我得到了一些undefined reference
的东西,这些东西是通过首先安装libsuitesparse-dev
然后编译g2o
来修复的
它对我有用,所以我希望对您也有用。
答案 1 :(得分:0)
我本来可以发表评论,但由于回复率太低而不能。
对我来说,将${CSPARSE_INCLUDE_DIR}
添加到target_link_libraries
就足够了。
因此,我的CMakeLists.txt中的行如下所示:
target_link_libraries(lsdslam ${FABMAP_LIB} ${G2O_LIBRARIES} ${catkin_LIBRARIES} ${CSPARSE_INCLUDE_DIR} cxsparse X11)
答案 2 :(得分:0)
(评论不足)
在过去的两个晚上,我也正为此而苦苦挣扎。 我发现出于某些原因,'libsuitesparse-dev'软件包的18.04 / bionic版本将普通的csparse文件遗漏了。现在只有一个“ libcxsparse3”。 https://packages.ubuntu.com/bionic/libsuitesparse-dev
如果您返回的是ubuntu版本,您会发现它曾经具有“普通” csparse文件。 https://packages.ubuntu.com/xenial/libsuitesparse-dev
更新: 我提交了Ubuntu错误报告,但得到的答复是libcsparse已被libcxsparse取代。
”“谢谢您的错误报告,这是需要的更改,而不是错误,据 https://salsa.debian.org/science-team/suitesparse/-/commit/3b00ddd5 '+ CSparse(libcsparse)的Drop包,由libcxsparse取代。 ,您尝试过使用它吗?”
**更改于:suitesparse(Ubuntu) 状态:新建=>无效