HuajianUP / Photo-SLAM

[CVPR 2024] Photo-SLAM: Real-time Simultaneous Localization and Photorealistic Mapping for Monocular, Stereo, and RGB-D Cameras
GNU General Public License v3.0
295 stars 25 forks source link

I'm having some problems compiling your code. #2

Closed Tianci-Wen closed 2 months ago

Tianci-Wen commented 2 months ago

Excellent work! I'm having some problems compiling, can you help me see if you've encountered any? Is there any solution?

my enviornment:

lzy@lzy:~/workingspace/Photo-SLAM$ ./build.sh 
mkdir: cannot create directory ‘build’: File exists
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/lzy/workingspace/Photo-SLAM/ORB-SLAM3/Thirdparty/DBoW2/build
Consolidate compiler generated dependencies of target DBoW2
[100%] Built target DBoW2
mkdir: cannot create directory ‘build’: File exists
CMake Deprecation Warning at CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- BUILD TYPE:Release
-- Compiling on Unix
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lzy/workingspace/Photo-SLAM/ORB-SLAM3/Thirdparty/g2o/build
Consolidate compiler generated dependencies of target g2o
[100%] Built target g2o
mkdir: cannot create directory ‘build’: File exists
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lzy/workingspace/Photo-SLAM/ORB-SLAM3/Thirdparty/Sophus/build
Consolidate compiler generated dependencies of target test_common
Consolidate compiler generated dependencies of target test_se2
Consolidate compiler generated dependencies of target test_so2
Consolidate compiler generated dependencies of target test_se3
Consolidate compiler generated dependencies of target test_sim2
Consolidate compiler generated dependencies of target test_velocities
Consolidate compiler generated dependencies of target test_rxso2
Consolidate compiler generated dependencies of target test_sim3
Consolidate compiler generated dependencies of target test_rxso3
Consolidate compiler generated dependencies of target test_so3
Consolidate compiler generated dependencies of target HelloSO3
Consolidate compiler generated dependencies of target test_geometry
[  8%] Built target test_common
[ 16%] Built target test_se2
[ 25%] Built target test_so2
[ 33%] Built target test_se3
[ 41%] Built target test_velocities
[ 50%] Built target test_sim2
[ 58%] Built target HelloSO3
[ 66%] Built target test_sim3
[ 83%] Built target test_geometry
[ 83%] Built target test_rxso3
[ 91%] Built target test_rxso2
[100%] Built target test_so3
Uncompress vocabulary ...
mkdir: cannot create directory ‘build’: File exists
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

Build type: Release
-- Using flag -std=c++14.
OPENCV VERSION:
4.7.0
CMake Warning at CMakeLists.txt:43 (find_package):
  By not providing "Findrealsense2.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "realsense2", but CMake did not find one.

  Could not find a package configuration file provided by "realsense2" with
  any of the following names:

    realsense2Config.cmake
    realsense2-config.cmake

  Add the installation prefix of "realsense2" to CMAKE_PREFIX_PATH or set
  "realsense2_DIR" to a directory containing one of the above files.  If
  "realsense2" provides a separate development package or SDK, be sure it has
  been installed.

CMake Deprecation Warning at Thirdparty/g2o/CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- BUILD TYPE:Release
-- Compiling on Unix
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lzy/workingspace/Photo-SLAM/ORB-SLAM3/build
Consolidate compiler generated dependencies of target g2o
Consolidate compiler generated dependencies of target ORB_SLAM3
[ 51%] Built target g2o
[100%] Built target ORB_SLAM3
Building Photo-SLAM ...
mkdir: cannot create directory ‘build’: File exists
-- The CXX compiler identification is GNU 9.4.0
-- The CUDA compiler identification is NVIDIA 11.8.89
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda-11.8/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Found CUDA: /usr/local/cuda-11.8 (found version "11.8") 
-- Caffe2: CUDA detected: 11.8
-- Caffe2: CUDA nvcc is: /usr/local/cuda-11.8/bin/nvcc
-- Caffe2: CUDA toolkit directory: /usr/local/cuda-11.8
-- Caffe2: Header version is: 11.8
CMake Warning at lib/libtorch/share/cmake/Caffe2/public/cuda.cmake:166 (message):
  Failed to compute shorthash for libnvrtc.so
Call Stack (most recent call first):
  lib/libtorch/share/cmake/Caffe2/Caffe2Config.cmake:88 (include)
  lib/libtorch/share/cmake/Torch/TorchConfig.cmake:68 (find_package)
  CMakeLists.txt:21 (find_package)

-- Found CUDNN: /usr/local/cuda-11.8/lib64/libcudnn.so  
-- Autodetected CUDA architecture(s):  8.9
-- Added CUDA NVCC flags for: -gencode;arch=compute_89,code=sm_89
-- Found Torch: /home/lzy/workingspace/Photo-SLAM/lib/libtorch/lib/libtorch.so  
-- Found OpenCV: /usr/local (found suitable version "4.7.0", minimum required is "4") 
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
CMake Warning at CMakeLists.txt:36 (find_package):
  By not providing "Findrealsense2.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "realsense2", but CMake did not find one.

  Could not find a package configuration file provided by "realsense2" with
  any of the following names:

    realsense2Config.cmake
    realsense2-config.cmake

  Add the installation prefix of "realsense2" to CMAKE_PREFIX_PATH or set
  "realsense2_DIR" to a directory containing one of the above files.  If
  "realsense2" provides a separate development package or SDK, be sure it has
  been installed.

-- Configuring done
-- Generating done
-- Build files have been written to: /home/lzy/workingspace/Photo-SLAM/build
[  2%] Building CUDA object CMakeFiles/cuda_rasterizer.dir/src/operate_points.cu.o
[  6%] Building CUDA object CMakeFiles/cuda_rasterizer.dir/src/rasterize_points.cu.o
[  6%] Building CUDA object CMakeFiles/cuda_rasterizer.dir/src/stereo_vision.cu.o
[  8%] Building CUDA object CMakeFiles/simple_knn.dir/third_party/simple-knn/simple_knn.cu.o
[ 15%] Building CUDA object CMakeFiles/cuda_rasterizer.dir/cuda_rasterizer/backward.cu.o
[ 15%] Building CUDA object CMakeFiles/simple_knn.dir/third_party/simple-knn/spatial.cu.o
[ 15%] Building CUDA object CMakeFiles/cuda_rasterizer.dir/cuda_rasterizer/forward.cu.o
[ 17%] Building CUDA object CMakeFiles/cuda_rasterizer.dir/cuda_rasterizer/rasterizer_impl.cu.o
[ 20%] Building CXX object CMakeFiles/imgui.dir/viewer/imgui/imgui_draw.cpp.o
[ 22%] Building CXX object CMakeFiles/imgui.dir/viewer/imgui/imgui_demo.cpp.o
[ 26%] Building CXX object CMakeFiles/imgui.dir/viewer/imgui/imgui_impl_opengl3.cpp.o
[ 26%] Building CXX object CMakeFiles/imgui.dir/viewer/imgui/imgui_impl_glfw.cpp.o
[ 28%] Building CXX object CMakeFiles/imgui.dir/viewer/imgui/imgui_tables.cpp.o
[ 31%] Building CXX object CMakeFiles/imgui.dir/viewer/imgui/imgui.cpp.o
[ 33%] Building CXX object CMakeFiles/imgui.dir/viewer/imgui/imgui_widgets.cpp.o
/home/lzy/workingspace/Photo-SLAM/third_party/simple-knn/simple_knn.cu:23: warning: "__CUDACC__" redefined
   23 | #define __CUDACC__
      | 
<command-line>: note: this is the location of the previous definition
/home/lzy/workingspace/Photo-SLAM/third_party/simple-knn/simple_knn.cu:23: warning: "__CUDACC__" redefined
   23 | #define __CUDACC__
      | 
<command-line>: note: this is the location of the previous definition
[ 35%] Linking CXX shared library ../lib/libimgui.so
[ 35%] Built target imgui
[ 37%] Linking CUDA shared library ../lib/libsimple_knn.so
[ 37%] Built target simple_knn
[ 40%] Built target cuda_rasterizer
[ 42%] Building CXX object CMakeFiles/gaussian_mapper.dir/third_party/tinyply/tinyply.cpp.o
[ 44%] Building CXX object CMakeFiles/gaussian_mapper.dir/src/gaussian_parameters.cpp.o
[ 48%] Building CXX object CMakeFiles/gaussian_mapper.dir/src/gaussian_model.cpp.o
[ 48%] Building CXX object CMakeFiles/gaussian_mapper.dir/src/gaussian_rasterizer.cpp.o
[ 51%] Building CXX object CMakeFiles/gaussian_mapper.dir/src/gaussian_mapper.cpp.o
[ 53%] Building CXX object CMakeFiles/gaussian_mapper.dir/src/gaussian_keyframe.cpp.o
[ 55%] Building CXX object CMakeFiles/gaussian_mapper.dir/src/gaussian_scene.cpp.o
[ 57%] Building CXX object CMakeFiles/gaussian_mapper.dir/src/gaussian_renderer.cpp.o
[ 60%] Building CXX object CMakeFiles/gaussian_mapper.dir/src/gaussian_trainer.cpp.o
[ 62%] Linking CXX shared library /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so
[ 62%] Built target gaussian_mapper
[ 64%] Building CXX object CMakeFiles/gaussian_viewer.dir/viewer/imgui_viewer.cpp.o
[ 66%] Building CXX object CMakeFiles/gaussian_viewer.dir/viewer/map_drawer.cpp.o
[ 68%] Linking CXX shared library /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_viewer.so
[ 68%] Built target gaussian_viewer
[ 71%] Building CXX object CMakeFiles/train_colmap.dir/examples/train_colmap.cpp.o
[ 73%] Building CXX object CMakeFiles/replica_mono.dir/examples/replica_mono.cpp.o
[ 75%] Building CXX object CMakeFiles/euroc_stereo.dir/examples/euroc_stereo.cpp.o
[ 77%] Building CXX object CMakeFiles/replica_rgbd.dir/examples/replica_rgbd.cpp.o
[ 80%] Building CXX object CMakeFiles/view_result.dir/examples/view_result.cpp.o
[ 82%] Building CXX object CMakeFiles/tum_mono.dir/examples/tum_mono.cpp.o
[ 84%] Building CXX object CMakeFiles/tum_rgbd.dir/examples/tum_rgbd.cpp.o
[ 86%] Linking CXX executable /home/lzy/workingspace/Photo-SLAM/bin/tum_mono
[ 88%] Linking CXX executable /home/lzy/workingspace/Photo-SLAM/bin/replica_mono
[ 91%] Linking CXX executable /home/lzy/workingspace/Photo-SLAM/bin/euroc_stereo
[ 93%] Linking CXX executable /home/lzy/workingspace/Photo-SLAM/bin/view_result
[ 95%] Linking CXX executable /home/lzy/workingspace/Photo-SLAM/bin/replica_rgbd
[ 97%] Linking CXX executable /home/lzy/workingspace/Photo-SLAM/bin/tum_rgbd
/usr/bin/ld: CMakeFiles/replica_mono.dir/examples/replica_mono.cpp.o: in function `main':
replica_mono.cpp:(.text.startup+0xa89): undefined reference to `ORB_SLAM3::System::System(std::string const&, std::string const&, ORB_SLAM3::System::eSensor, int, std::string const&)'
/usr/bin/ld: replica_mono.cpp:(.text.startup+0xe2b): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: replica_mono.cpp:(.text.startup+0xfb0): undefined reference to `ORB_SLAM3::System::TrackMonocular(cv::Mat const&, double const&, std::vector<ORB_SLAM3::IMU::Point, std::allocator<ORB_SLAM3::IMU::Point> > const&, std::string)'
/usr/bin/ld: replica_mono.cpp:(.text.startup+0x118d): undefined reference to `ORB_SLAM3::System::SaveTrajectoryTUM(std::string const&)'
/usr/bin/ld: replica_mono.cpp:(.text.startup+0x1207): undefined reference to `ORB_SLAM3::System::SaveKeyFrameTrajectoryTUM(std::/string constusr&/)bin'/
ld/:usr /CMakeFilesbin//tum_mono.dirld/:examples /replica_mono.cpptum_mono.cpp.o::( .intext.startup +function0x1281 )`:main 'undefined: 
referencetum_mono.cpp :to( .`text.startupORB_SLAM3+:0xa98:)System:: :undefinedSaveTrajectoryEuRoC (referencestd :to: string` ORB_SLAM3const:&:)System':
:/Systemusr(/stdbin:/:ldstring:  constreplica_mono.cpp&:,( .stdtext.startup:+:0x1310string) :const &undefined,  referenceORB_SLAM3 :to: System`:ORB_SLAM3::eSensor:,System :int:,SaveKeyFrameTrajectoryEuRoC (stdstd::::stringstring  constconst&&))''

//usrusr//binbin//ldld::  tum_mono.cpp/:home(/.lzytext.startup/+workingspace0xe9e/)Photo:- SLAMundefined/ libreference/ libgaussian_viewer.soto:  `undefinedcv :reference: imreadto( std`:cv::string: FileStorageconst:&:,FileStorage (intstd):':
string/ usrconst/&bin,/ ldint:,  tum_mono.cppstd::(:.stringtext.startup +const0x1085&)):' 
undefined/ usrreference/ binto/ ld`:ORB_SLAM3 :/:homeSystem/:lzy:/TrackMonocularworkingspace(/cvPhoto:-:SLAMMat/ libconst/&libgaussian_mapper.so,:  doubleundefined  constreference& ,to  std`:Json::vector:<ValueORB_SLAM3::::ValueIMU(:std::Point:,string  stdconst:&:)allocator'<
ORB_SLAM3/:usr:/IMUbin:/:ldPoint:>  />home /constlzy&/,workingspace /stdPhoto:-:SLAMstring/)lib'/
libgaussian_mapper.so/:usr /undefinedbin /referenceld :to  tum_mono.cpp`:cv(:.:text.startupFileNode+:0x12b1:)string:( )undefined  constreference' 
to/ usr`/ORB_SLAM3bin:/:ldSystem:: :/SaveTrajectoryTUMhome(/stdlzy:/:workingspacestring/ Photoconst-&SLAM)/'lib
//libgaussian_mapper.sousr:/ binundefined/ ldreference:  totum_mono.cpp :`(cv.:text.startup:+error0x132b()int:,  undefinedstd :reference: stringto  const`&ORB_SLAM3,: :charSystem :const:*SaveKeyFrameTrajectoryTUM,( stdchar: :conststring* ,const &int))''

//usrusr//binbin//ldld::  tum_mono.cpp/:home(/.lzytext.startup/+workingspace0x13a5/)Photo:- SLAMundefined/ libreference/ libgaussian_mapper.soto:  `undefinedORB_SLAM3 :reference: Systemto: :`SaveTrajectoryEuRoCcv(:std::imwrite:(stringstd :const:&string) 'const
&/,usr /cvbin:/:ld_InputArray:  consttum_mono.cpp&:,( .stdtext.startup:+:0x1434vector)<:int ,undefined  stdreference: :toallocator <`intORB_SLAM3>: :>System :const:&SaveKeyFrameTrajectoryEuRoC)('std
::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_viewer.so: undefined reference to `cv::FileStorage::FileStorage(std::string const&, int, std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `Json::Value::Value(std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::FileNode::string() const'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::imwrite(std::string const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/tum_mono.dir/build.make:186: /home/lzy/workingspace/Photo-SLAM/bin/tum_mono] Error 1
make[2]: *** [CMakeFiles/replica_mono.dir/build.make:186: /home/lzy/workingspace/Photo-SLAM/bin/replica_mono] Error 1
make[1]: *** [CMakeFiles/Makefile2:363: CMakeFiles/tum_mono.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:303: CMakeFiles/replica_mono.dir/all] Error 2
/usr/bin/ld: CMakeFiles/euroc_stereo.dir/examples/euroc_stereo.cpp.o: in function `main':
euroc_stereo.cpp:(.text.startup+0xadb): undefined reference to `ORB_SLAM3::System::System(std::string const&, std::string const&, ORB_SLAM3::System::eSensor, int, std::string const&)'
/usr/bin/ld: euroc_stereo.cpp:(.text.startup+0xea9): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: euroc_stereo.cpp:(.text.startup+0xedf): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: euroc_stereo.cpp:(.text.startup+0x10c2): undefined reference to `ORB_SLAM3::System::TrackStereo(cv::Mat const&, cv::Mat const&, double const&, std::vector<ORB_SLAM3::IMU::Point, std::allocator<ORB_SLAM3::IMU::Point> > const&, std::string)'
/usr/bin/ld: euroc_stereo.cpp:(.text.startup+0x1305): undefined reference to `ORB_SLAM3::System::SaveTrajectoryTUM(std::string const&)'
/usr/bin/ld: euroc_stereo.cpp:(.text.startup+0x1386): undefined reference to `ORB_SLAM3::System::SaveKeyFrameTrajectoryTUM(std::string const&)'
/usr/bin/ld: euroc_stereo.cpp:(.text.startup+0x1407): undefined reference to `ORB_SLAM3::System::SaveTrajectoryEuRoC(std::string const&)'
/usr/bin/ld: euroc_stereo.cpp:(.text.startup+0x149f): undefined reference to `ORB_SLAM3::System::SaveKeyFrameTrajectoryEuRoC(std::string const&)'
/usr/bin/ld: euroc_stereo.cpp:(.text.startup+0x1520): undefined reference to `ORB_SLAM3::System::SaveTrajectoryKITTI(std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_viewer.so: undefined reference to `cv::FileStorage::FileStorage(std::string const&, int, std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `Json::Value::Value(std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::FileNode::string() const'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::imwrite(std::string const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/euroc_stereo.dir/build.make:186: /home/lzy/workingspace/Photo-SLAM/bin/euroc_stereo] Error 1
make[1]: *** [CMakeFiles/Makefile2:423: CMakeFiles/euroc_stereo.dir/all] Error 2
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_viewer.so: undefined reference to `cv::FileStorage::FileStorage(std::string const&, int, std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `Json::Value::Value(std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::FileNode::string() const'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::imwrite(std::string const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/view_result.dir/build.make:186: /home/lzy/workingspace/Photo-SLAM/bin/view_result] Error 1
make[1]: *** [CMakeFiles/Makefile2:273: CMakeFiles/view_result.dir/all] Error 2
[100%] Linking CXX executable /home/lzy/workingspace/Photo-SLAM/bin/train_colmap
/usr/bin/ld: CMakeFiles/replica_rgbd.dir/examples/replica_rgbd.cpp.o: in function `main':
replica_rgbd.cpp:(.text.startup+0xb57): undefined reference to `ORB_SLAM3::System::System(std::string const&, std::string const&, ORB_SLAM3::System::eSensor, int, std::string const&)'
/usr/bin/ld: replica_rgbd.cpp:(.text.startup+0xf25): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: replica_rgbd.cpp:(.text.startup+0xfa9): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: replica_rgbd.cpp:(.text.startup+0x1174): undefined reference to `ORB_SLAM3::System::TrackRGBD(cv::Mat const&, cv::Mat const&, double const&, std::vector<ORB_SLAM3::IMU::Point, std::allocator<ORB_SLAM3::IMU::Point> > const&, std::string)'
/usr/bin/ld: replica_rgbd.cpp:(.text.startup+0x142f): undefined reference to `ORB_SLAM3::System::SaveTrajectoryTUM(std::string const&)'
/usr/bin/ld: replica_rgbd.cpp:(.text.startup+0x14b0): undefined reference to `ORB_SLAM3::System::SaveKeyFrameTrajectoryTUM(std::string const&)'
/usr/bin/ld: replica_rgbd.cpp:(.text.startup+0x1531): undefined reference to `ORB_SLAM3::System::SaveTrajectoryEuRoC(std::string const&)'
/usr/bin/ld: replica_rgbd.cpp:(.text.startup+0x15c9): undefined reference to `ORB_SLAM3::System::SaveKeyFrameTrajectoryEuRoC(std::string const&)'
/usr/bin/ld: replica_rgbd.cpp:(.text.startup+0x164a): undefined reference to `ORB_SLAM3::System::SaveTrajectoryKITTI(std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_viewer.so: undefined reference to `cv::FileStorage::FileStorage(std::string const&, int, std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `Json::Value::Value(std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::FileNode::string() const'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::imwrite(std::string const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/replica_rgbd.dir/build.make:186: /home/lzy/workingspace/Photo-SLAM/bin/replica_rgbd] Error 1
make[1]: *** [CMakeFiles/Makefile2:333: CMakeFiles/replica_rgbd.dir/all] Error 2
/usr/bin/ld: CMakeFiles/tum_rgbd.dir/examples/tum_rgbd.cpp.o: in function `main':
tum_rgbd.cpp:(.text.startup+0xb5d): undefined reference to `ORB_SLAM3::System::System(std::string const&, std::string const&, ORB_SLAM3::System::eSensor, int, std::string const&)'
/usr/bin/ld: tum_rgbd.cpp:(.text.startup+0xfd9): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: tum_rgbd.cpp:(.text.startup+0x111c): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: tum_rgbd.cpp:(.text.startup+0x133b): undefined reference to `ORB_SLAM3::System::TrackRGBD(cv::Mat const&, cv::Mat const&, double const&, std::vector<ORB_SLAM3::IMU::Point, std::allocator<ORB_SLAM3::IMU::Point> > const&, std::string)'
/usr/bin/ld: tum_rgbd.cpp:(.text.startup+0x16db): undefined reference to `ORB_SLAM3::System::SaveTrajectoryTUM(std::string const&)'
/usr/bin/ld: tum_rgbd.cpp:(.text.startup+0x1757): undefined reference to `ORB_SLAM3::System::SaveKeyFrameTrajectoryTUM(std::string const&)'
/usr/bin/ld: tum_rgbd.cpp:(.text.startup+0x17d3): undefined reference to `ORB_SLAM3::System::SaveTrajectoryEuRoC(std::string const&)'
/usr/bin/ld: tum_rgbd.cpp:(.text.startup+0x1866): undefined reference to `ORB_SLAM3::System::SaveKeyFrameTrajectoryEuRoC(std::string const&)'
/usr/bin/ld: tum_rgbd.cpp:(.text.startup+0x18e2): undefined reference to `ORB_SLAM3::System::SaveTrajectoryKITTI(std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_viewer.so: undefined reference to `cv::FileStorage::FileStorage(std::string const&, int, std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `Json::Value::Value(std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::FileNode::string() const'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::imwrite(std::string const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/tum_rgbd.dir/build.make:186: /home/lzy/workingspace/Photo-SLAM/bin/tum_rgbd] Error 1
make[1]: *** [CMakeFiles/Makefile2:393: CMakeFiles/tum_rgbd.dir/all] Error 2
/usr/bin/ld: CMakeFiles/train_colmap.dir/examples/train_colmap.cpp.o: in function `readColmapImagesBinary(std::shared_ptr<GaussianMapper>, std::filesystem::path const&, std::filesystem::path const&)':
train_colmap.cpp:(.text+0xc39): undefined reference to `cv::imread(std::string const&, int)'
/usr/bin/ld: CMakeFiles/train_colmap.dir/examples/train_colmap.cpp.o: in function `readColmapCamerasBinary(std::shared_ptr<GaussianMapper>, std::filesystem::path const&)':
train_colmap.cpp:(.text+0x351f): undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'
/usr/bin/ld: train_colmap.cpp:(.text+0x356d): undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'
/usr/bin/ld: train_colmap.cpp:(.text+0x35a4): undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'
/usr/bin/ld: train_colmap.cpp:(.text+0x35db): undefined reference to `cv::error(int, std::string const&, char const*, char const*, int)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_viewer.so: undefined reference to `cv::FileStorage::FileStorage(std::string const&, int, std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `Json::Value::Value(std::string const&)'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::FileNode::string() const'
/usr/bin/ld: /home/lzy/workingspace/Photo-SLAM/lib/libgaussian_mapper.so: undefined reference to `cv::imwrite(std::string const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/train_colmap.dir/build.make:186: /home/lzy/workingspace/Photo-SLAM/bin/train_colmap] Error 1
make[1]: *** [CMakeFiles/Makefile2:243: CMakeFiles/train_colmap.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
liquorleaf commented 2 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?

Tianci-Wen commented 2 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?

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()
Tianci-Wen commented 2 months ago

I would like to ask if you can provide a docker container, so that there should be no problem with the environment.

liquorleaf commented 2 months ago

Could you find the target symbols in the .so libs by command like ?

nm -C ./ORB-SLAM3/lib/libORB_SLAM3.so | grep "TrackMonocular"
Tianci-Wen commented 2 months ago

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 : image

Tianci-Wen commented 2 months ago

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 : image

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.

Tianci-Wen commented 2 months ago

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.

mumu2000mumu commented 2 months ago

同学您好,我也遇到了相同的问题,并且找不出原因,

Tianci-Wen commented 2 months ago

同学您好,我也遇到了相同的问题,并且找不出原因,

我建议使用docker配置你的环境,并且把所有环境与这个代码中要求配置一致

mumu2000mumu commented 2 months ago

好的谢谢

Eragonlrc commented 2 months ago

同学您好,我也在环境配置上遇到了问题,请问您是否方便分享一下使用的docker镜像? @Tianci-Wen

XuYinzhe commented 2 months ago

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
vulnic commented 3 weeks ago

image 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.