Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation issues and solutions #9

Open
petern3 opened this issue Mar 15, 2017 · 1 comment
Open

Compilation issues and solutions #9

petern3 opened this issue Mar 15, 2017 · 1 comment

Comments

@petern3
Copy link

petern3 commented Mar 15, 2017

I have come across various compilation issues and solved them, so I'll put the process here for everyone else. I may not have the same problems as other people, but hopefully this is helpful!

Operating System: Windows 10, 64 bit
Compiler: Visual Studio 2015

Half of the changes are to support more recent libraries such as OpenCV3 and Eigen3. I think these are all the changes I made:

(1) g2o can't find BLAS and LAPACK. The original ORB_SLAM2 g2o CMakeLists.txt file has removed the following two lines, and it seems to work:

-    FIND_PACKAGE(BLAS REQUIRED)
-    FIND_PACKAGE(LAPACK REQUIRED)

I also removed the g2o cmake_modules folder, since it apparently isn't needed either. I think it works because BLAS and LAPACK are in Eigen3?

(2) Every time there was an OpenCV dependency, I changed the following lines to support OpenCV3. This is only necessary if you use 3:

  -    find_package(OpenCV 2.4.3 REQUIRED)
  +    find_package(OpenCV 3.0 QUIET)
  +    if(NOT OpenCV_FOUND)
  +       find_package(OpenCV 2.4.3 REQUIRED)
  +    endif()

(3) I also had to change line 56 of linear_solver_eigen.h to support eigen3.3 (g2o will compile without this change, ORB_SLAM2 may not):

-    typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, SparseMatrix::Index> PermutationMatrix;
+    typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic> PermutationMatrix;

(4) When configuring ORB_SLAM2 itself, I had another issue in PangolinConfig.cmake, so I've fixed by removing:

-    add_library(_libjpeg STATIC IMPORTED)
-    set_target_properties(_libjpeg PROPERTIES
-        IMPORTED_LOCATION C:/Program Files/Pangolin/build/external/libjpeg/lib/jpeg.lib
-    )

Important: I also put quotes around all of directories in that file.

(5) If the linker can't find anything such as "_libjpeg", go into Project -> Properties -> Linker -> Input, and into Additional Dependencies. Double check all the values in there. As for _libjpeg.lib, I replaced it with C:/Program Files/Pangolin/build/external/libjpeg/lib/jpeg.lib (or the relevant location).

(6) It also complained about a runtime library mismatch. The two options are:

  1. RECOMMENDED: recompile Pangolin as a DLL (check BUILD_SHARED_LIBS is ON and MSVC_USE_STATIC_CRT to OFF in CMake).
  2. Go into ORB_SLAM2 Project -> Properties -> C/C++ -> Code Generation, set Runtime Library from Multi-threaded DLL (/MD) to Multi-threaded (/MT). You may need to do this for each individual project. I didn't get this method to work, because it would involve a lot of recompiling.

Also make sure that each time you compile something, the Debug/Release mode is consistent.

@petern3 petern3 mentioned this issue Mar 15, 2017
@petern3
Copy link
Author

petern3 commented Mar 15, 2017

Okay, things are getting a bit hacky now. To use ORB_SLAM2 in my own program with CMake, I have used

set(ORB_SLAM2 "C:/Program Files/ORB_SLAM2/build/Release/ORB_SLAM2.lib")
include_directories("C:/Program Files/ORB_SLAM2/include")

set(DBOW2 "C:/Program Files/ORB_SLAM2/Thirdparty/DBoW2/bin/Release/dbow2.lib")
include_directories("C:/Program Files/ORB_SLAM2/Thirdparty/DBoW2/dbow2")

set(G2O "C:/Program Files/ORB_SLAM2/Thirdparty/g2o/bin/Release/g2o.lib")
include_directories("C:/Program Files/ORB_SLAM2/Thirdparty/g2o")

I also had to change the following line in LoopClosing.h:

-    #include "Thirdparty/g2o/g2o/types/types_seven_dof_expmap.h"
+    #include "g2o/types/types_seven_dof_expmap.h"

and copy the g2o config file into the g2o subfolder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant