Closed Tianci-Wen closed 7 months ago
Seems like your linker failed to find symbols of opencv, jsoncpp, ORB_SLAM3, etc. Have you tried a newer version of cmake? Did you change anything in CMakeLists.txt?
Seems like your linker failed to find symbols of opencv, jsoncpp, ORB_SLAM3, etc. Have you tried a newer version of cmake? Did you change anything in CMakeLists.txt?
I update my cmake to 3.27.5, but it resport the same error that it failed to link opencv, ORB_SLAM3, etc.
For the CMakeLists.txt, I just add set(Torch_DIR /home/lzy/workingspace/Photo-SLAM/lib/libtorch/share/cmake/Torch)
. Now I'm trying to set path for these library.
For the build.sh, I modify make -j8
to make -j128
. I have tried with make -j8
, same error.
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release # add OpenCV_DIR definitions if needed, example:
#cmake .. -DCMAKE_BUILD_TYPE=Release -DOpenCV_DIR=/home/rapidlab/libs/opencv/lib/cmake/opencv4
make -j128
# Photo-SLAM
echo "Building Photo-SLAM ..."
cd ../..
mkdir build
cd build
cmake .. # add Torch_DIR and/or OpenCV_DIR definitions if needed, example:
#cmake .. -DTorch_DIR=/home/rapidlab/libs/libtorch/share/cmake/Torch -DOpenCV_DIR=/home/rapidlab/libs/opencv/lib/cmake/opencv4
make -j128
Here is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(photo-slam LANGUAGES CXX CUDA)
if(NOT CMAKE_BUILD_TYPE)
# set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
set(CAFFE2_USE_CUDNN on)
# Uncomment the following line if you want to solve CMake Warning "Failed to compute shorthash for libnvrtc.so"
# set(PYTHON_EXECUTABLE "/usr/bin/python3")
set(Torch_DIR /home/lzy/workingspace/Photo-SLAM/lib/libtorch/share/cmake/Torch)
find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS} -pthread")
# set(ENV{CUDA_LAUNCH_BLOCKING} 1)
# set(ENV{TORCH_USE_CUDA_DSA} 1)
find_package(CUDA REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(OpenCV 4 REQUIRED)
find_package(jsoncpp REQUIRED)
find_package(OpenGL REQUIRED)
find_package(glm REQUIRED)
find_package(glfw3 REQUIRED)
find_package(realsense2)
set(ORB_SLAM3_SOURCE_DIR "${PROJECT_SOURCE_DIR}/ORB-SLAM3")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
include_directories(
${PROJECT_SOURCE_DIR}
${ORB_SLAM3_SOURCE_DIR}
${ORB_SLAM3_SOURCE_DIR}/include
${ORB_SLAM3_SOURCE_DIR}/include/CameraModels
${ORB_SLAM3_SOURCE_DIR}/Thirdparty/Sophus
${EIGEN3_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR})
##################################################################################
## Build the gaussian splatting component libraries to ${PROJECT_SOURCE_DIR}/lib
##################################################################################
add_library(simple_knn SHARED
third_party/simple-knn/simple_knn.cu
third_party/simple-knn/simple_knn.h
third_party/simple-knn/spatial.cu
third_party/simple-knn/spatial.h)
# target_compile_features(simple_knn PUBLIC cxx_std_17)
target_link_libraries(simple_knn "${TORCH_LIBRARIES}")
add_library(cuda_rasterizer SHARED
include/operate_points.h
src/operate_points.cu
include/rasterize_points.h
src/rasterize_points.cu
include/stereo_vision.h
src/stereo_vision.cu
cuda_rasterizer/auxiliary.h
cuda_rasterizer/backward.cu
cuda_rasterizer/backward.h
cuda_rasterizer/config.h
cuda_rasterizer/forward.cu
cuda_rasterizer/forward.h
cuda_rasterizer/operate_points.h
cuda_rasterizer/rasterizer.h
cuda_rasterizer/rasterizer_impl.cu
cuda_rasterizer/rasterizer_impl.h
cuda_rasterizer/stereo_vision.h)
set_target_properties(cuda_rasterizer PROPERTIES CUDA_ARCHITECTURES "75;86")
# target_compile_features(cuda_rasterizer PUBLIC cxx_std_17)
target_include_directories(cuda_rasterizer PRIVATE
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
target_link_libraries(cuda_rasterizer
glm::glm
"${TORCH_LIBRARIES}"
Eigen3::Eigen)
##################################################################################
## Build the ImGui library to ${PROJECT_SOURCE_DIR}/lib
##################################################################################
add_library(imgui SHARED
viewer/imgui/imconfig.h
viewer/imgui/imgui_demo.cpp
viewer/imgui/imgui_draw.cpp
viewer/imgui/imgui_impl_glfw.cpp
viewer/imgui/imgui_impl_glfw.h
viewer/imgui/imgui_impl_opengl3_loader.h
viewer/imgui/imgui_impl_opengl3.cpp
viewer/imgui/imgui_impl_opengl3.h
viewer/imgui/imgui_internal.h
viewer/imgui/imgui_tables.cpp
viewer/imgui/imgui_widgets.cpp
viewer/imgui/imgui.cpp
viewer/imgui/imgui.h
viewer/imgui/imstb_rectpack.h
viewer/imgui/imstb_textedit.h
viewer/imgui/imstb_truetype.h)
target_link_libraries(imgui glfw OpenGL::GL)
##################################################################################
## Build the gaussian mapper library to ${PROJECT_SOURCE_DIR}/lib
##################################################################################
add_library(gaussian_mapper SHARED
third_party/tinyply/tinyply.h
third_party/tinyply/tinyply.cpp
include/gaussian_keyframe.h
include/gaussian_model.h
include/gaussian_parameters.h
include/gaussian_rasterizer.h
include/gaussian_renderer.h
include/gaussian_scene.h
include/gaussian_trainer.h
include/gaussian_mapper.h
include/general_utils.h
include/graphics_utils.h
include/loss_utils.h
include/sh_utils.h
include/tensor_utils.h
include/camera.h
include/point_cloud.h
include/point2d.h
include/point3d.h
include/types.h
src/gaussian_keyframe.cpp
src/gaussian_model.cpp
src/gaussian_parameters.cpp
src/gaussian_rasterizer.cpp
src/gaussian_renderer.cpp
src/gaussian_scene.cpp
src/gaussian_trainer.cpp
src/gaussian_mapper.cpp)
target_link_libraries(gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so
${OpenCV_LIBRARIES}
jsoncpp_lib
"${TORCH_LIBRARIES}"
Eigen3::Eigen
simple_knn
cuda_rasterizer)
##################################################################################
## Build the viewer library to ${PROJECT_SOURCE_DIR}/lib
##################################################################################
add_library(gaussian_viewer SHARED
viewer/drawer_utils.h
viewer/imgui_viewer.cpp
viewer/imgui_viewer.h
viewer/map_drawer.cpp
viewer/map_drawer.h)
target_link_libraries(gaussian_viewer
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so
gaussian_mapper
imgui
${OpenCV_LIBRARIES}
jsoncpp_lib
"${TORCH_LIBRARIES}"
glm::glm
glfw
OpenGL::GL)
##################################################################################
## Build the test examples to ${PROJECT_SOURCE_DIR}/bin
##################################################################################
# This is a C++ libtorch implementation of gaussian-splatting (https://github.com/graphdeco-inria/gaussian-splatting)
add_executable(train_colmap examples/train_colmap.cpp)
target_link_libraries(train_colmap
gaussian_viewer
gaussian_mapper)
add_executable(view_result examples/view_result.cpp)
target_link_libraries(view_result
gaussian_viewer
gaussian_mapper)
##################################################################################
## Build the mapping examples to ${PROJECT_SOURCE_DIR}/bin
##################################################################################
# Replica Monocular
add_executable(replica_mono examples/replica_mono.cpp)
target_link_libraries(replica_mono
gaussian_viewer
gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so)
# Replica Monocular
add_executable(replica_rgbd examples/replica_rgbd.cpp)
target_link_libraries(replica_rgbd
gaussian_viewer
gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so)
# TUM Monocular
add_executable(tum_mono examples/tum_mono.cpp)
target_link_libraries(tum_mono
gaussian_viewer
gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so)
# TUM RGBD
add_executable(tum_rgbd examples/tum_rgbd.cpp)
target_link_libraries(tum_rgbd
gaussian_viewer
gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so)
# EuRoC Stereo
add_executable(euroc_stereo examples/euroc_stereo.cpp)
target_link_libraries(euroc_stereo
gaussian_viewer
gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so)
##################################################################################
## Build the mapping examples to ${PROJECT_SOURCE_DIR}/bin
##################################################################################
# Intel Realsense
if(realsense2_FOUND)
add_executable(realsense_rgbd examples/realsense_rgbd.cpp)
target_include_directories(realsense_rgbd PUBLIC
${realsense_INCLUDE_DIR})
target_link_libraries(realsense_rgbd
gaussian_viewer
gaussian_mapper
${ORB_SLAM3_SOURCE_DIR}/lib/libORB_SLAM3.so
${realsense2_LIBRARY})
endif()
I would like to ask if you can provide a docker container, so that there should be no problem with the environment.
Could you find the target symbols in the .so libs by command like ?
nm -C ./ORB-SLAM3/lib/libORB_SLAM3.so | grep "TrackMonocular"
Could you find the target symbols in the .so libs by command like ?
nm -C ./ORB-SLAM3/lib/libORB_SLAM3.so | grep "TrackMonocular"
It does seem to find this function in libORB_SLAM3.so :
Could you find the target symbols in the .so libs by command like ?
nm -C ./ORB-SLAM3/lib/libORB_SLAM3.so | grep "TrackMonocular"
It does seem to find this function in libORB_SLAM3.so :
What it want is ORB_SLAM3::System::TrackMonocular(cv::Mat const&, double const&, std::vector<ORB_SLAM3::IMU::Point, std::allocator<ORB_SLAM3::IMU::Point> > const&, std::string)'
. In libORB_SLAM3.so, it is
lzy@lzy:~/workingspace/Photo-SLAM$ nm -C ./ORB-SLAM3/lib/libORB_SLAM3.so | grep "ORB_SLAM3::System::TrackMonocular"
0000000000142bc0 T ORB_SLAM3::System::TrackMonocular(cv::Mat const&, double const&, std::vector<ORB_SLAM3::IMU::Point, std::allocator<ORB_SLAM3::IMU::Point> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >).
They are different in the final input parameter std::string
and std::allocator<ORB_SLAM3::IMU::Point> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >
.
I'm wondering if there's something wrong with my gcc version.
After configuring the environment on docker, I successfully compiled and ran the replica data set. There may be some problems with the C++ environment of my computer.
同学您好,我也遇到了相同的问题,并且找不出原因,
同学您好,我也遇到了相同的问题,并且找不出原因,
我建议使用docker配置你的环境,并且把所有环境与这个代码中要求配置一致
好的谢谢
同学您好,我也在环境配置上遇到了问题,请问您是否方便分享一下使用的docker镜像? @Tianci-Wen
I can successfully compile using the Dockerfile:
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
software-properties-common \
wget
# gcc
RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y
RUN apt-get install -y gcc-11 g++-11
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 100
# dependency
RUN apt-get install -y \
git \
build-essential \
sudo \
libeigen3-dev \
libboost-all-dev \
libjsoncpp-dev \
libopengl-dev \
mesa-utils \
libglfw3-dev \
libglm-dev \
python3-pip \
python3-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
curl \
zip \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libswresample-dev \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# cmake
RUN wget https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1-Linux-x86_64.sh -O /cmake-3.22.1.sh && \
chmod +x /cmake-3.22.1.sh && \
/cmake-3.22.1.sh --skip-license --prefix=/usr/local
# opencv
RUN mkdir /opencv && cd /opencv && \
wget https://github.com/opencv/opencv/archive/refs/tags/4.8.0.zip -O opencv-4.8.0.zip && \
wget https://github.com/opencv/opencv_contrib/archive/refs/tags/4.8.0.zip -O opencv_contrib-4.8.0.zip && \
unzip opencv-4.8.0.zip && \
unzip opencv_contrib-4.8.0.zip && \
rm opencv-4.8.0.zip && rm opencv_contrib-4.8.0.zip
RUN mkdir /opencv/opencv-4.8.0/build && cd /opencv/opencv-4.8.0/build && \
cmake -DCMAKE_BUILD_TYPE=RELEASE \
-DWITH_CUDA=ON \
-DWITH_CUDNN=ON \
-DOPENCV_DNN_CUDA=ON \
-DWITH_NVCUVID=ON \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.8 \
-DOPENCV_EXTRA_MODULES_PATH=/opencv/opencv_contrib-4.8.0/modules \
-DBUILD_TIFF=ON \
-DBUILD_ZLIB=ON \
-DBUILD_JASPER=ON \
-DBUILD_JPEG=ON \
-DWITH_FFMPEG=ON \
.. && \
make -j$(nproc) && \
make install && \
ldconfig
# libtorch
RUN cd / && \
wget https://download.pytorch.org/libtorch/cu118/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcu118.zip -O libtorch-cu118.zip && \
unzip libtorch-cu118.zip && rm libtorch-cu118.zip
ENV Torch_DIR /libtorch/share/cmake/Torch
# repo
RUN git clone https://github.com/HuajianUP/Photo-SLAM.git /Photo-SLAM
WORKDIR /Photo-SLAM
Had an issue with the build.sh using the above dockerfile, but solved it.
Adding Torch_DIR to the last cmake ..
call (as suggested in the comment) of the build.sh
solved it for me!
I did not add the -DOpen_CV
variable, as I could not find the equivalent directory within the container.
cmake .. -DTorch_DIR=/libtorch/share/cmake/Torch
without -DOpen_CV
你好,这个项目可以生成稠密点云和轨迹图吗?
同时,这个项目如何部署在真实世界中。并且在docker中没有图形化节面改怎么查看结果呢?
同时,这个项目如何部署在真实世界中。并且在docker中没有图形化节面改怎么查看结果呢?
可以将画面映射到宿主机
Excellent work! I'm having some problems compiling, can you help me see if you've encountered any? Is there any solution?
my enviornment: