UZ-SLAMLab / ORB_SLAM3

ORB-SLAM3: An Accurate Open-Source Library for Visual, Visual-Inertial and Multi-Map SLAM
GNU General Public License v3.0
6.59k stars 2.56k forks source link

building issue #46

Open belal-ibrahim opened 4 years ago

belal-ibrahim commented 4 years ago

I am trying to build it using ./build.sh and i got this type of error: note that i am using ubuntu 20.04 /home/beraru/ORB_SLAM3/src/Optimizer.cc: In static member function ‘static void ORB_SLAM3::Optimizer::MergeInertialBA(ORB_SLAM3::KeyFrame, ORB_SLAM3::KeyFrame, bool, ORB_SLAM3::Map, ORB_SLAM3::LoopClosing::KeyFrameAndPose&)’: /home/beraru/ORB_SLAM3/src/Optimizer.cc:7015:19: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else] 7015 | if(!pMP->isBad()) | ^ /home/beraru/ORB_SLAM3/src/Optimizer.cc: In static member function ‘static int ORB_SLAM3::Optimizer::PoseInertialOptimizationLastKeyFrame(ORB_SLAM3::Frame*, bool)’: /home/beraru/ORB_SLAM3/src/Optimizer.cc:7706:10: warning: unused variable ‘bOut’ [-Wunused-variable] 7706 | bool bOut = false; | ^~~~ /home/beraru/ORB_SLAM3/src/LocalMapping.cc: In member function ‘void ORB_SLAM3::LocalMapping::KeyFrameCulling()’: /home/beraru/ORB_SLAM3/src/LocalMapping.cc:1057:48: warning: ‘last_ID’ may be used uninitialized in this function [-Wmaybe-uninitialized] 1057 | if((bInitImu && (pKF->mnId<last_ID) && t<3.) || (t<0.5)) | ^~~ make[2]: [CMakeFiles/ORB_SLAM3.dir/build.make:102: CMakeFiles/ORB_SLAM3.dir/src/LoopClosing.cc.o] Error 1 /home/beraru/ORB_SLAM3/src/Tracking.cc: In member function ‘void ORB_SLAM3::Tracking::Track()’: /home/beraru/ORB_SLAM3/src/Tracking.cc:1155:13: warning: ‘bOK’ may be used uninitialized in this function [-Wmaybe-uninitialized] 1155 | if(bOK) | ^~ make[2]: [CMakeFiles/ORB_SLAM3.dir/build.make:232: CMakeFiles/ORB_SLAM3.dir/src/Optimizer.cc.o] Error 1 make[1]: [CMakeFiles/Makefile2:390: CMakeFiles/ORB_SLAM3.dir/all] Error 2 make: [Makefile:84: all] Error 2

ns15417 commented 4 years ago

Did you post all your error info? I only saw the whole message of all kinds of warnings which can be neglected. For Error 1, it only mentions LoopCLosing.cc.o, are there more details of the log

jj-gomez commented 4 years ago

Hi @belal-ibrahim, I would ask you next time only post the error messages and not all the warnings (either by modifiying the compiler flags at CMakeLists.txt or by only copying the error lines) to facilitate the readability of the message.

Regarding your problem, it looks like a problem when finding the file openssl/md5.h. You should first install in your system the openssl library (https://cloudwafer.com/blog/installing-openssl-on-ubuntu-16-04-18-04/). If after this, errors keep poping up, please copy us the error messages you are getting!

Regards

ns15417 commented 4 years ago

According to the log, you donot include the file openssl/md5.h which belong to the lib crypto which should be linked in CMakelists.txt. SO you should check whether crypto is installed or rightly installed. OR you can delete the line #include openssl/md5.h in System.cc cuz the code used md5 is noted in System.cc. you can check the function System::CalculateCheckSum() to have a look. it has never been used.

belal-ibrahim commented 4 years ago

I have installed openssl as mentioned by @jjgr3496 and it solved openssl error. However, i still got some errors for @ns15417 i have commented openssl in system.cc as a final trial and that's the only error i got:

/home/beraru/ORB_SLAM3/src/Optimizer.cc:2388:37: required from here /usr/include/c++/9/bits/stl_map.h:122:71: error: static assertion failed: std::map must have the same value_type as its allocator 122 | static_assert(is_same<typename _Alloc::value_type, value_type>::value,

make[2]: [CMakeFiles/ORB_SLAM3.dir/build.make:102: CMakeFiles/ORB_SLAM3.dir/src/LoopClosing.cc.o] Error 1 make[2]: [CMakeFiles/ORB_SLAM3.dir/build.make:232: CMakeFiles/ORB_SLAM3.dir/src/Optimizer.cc.o] Error 1 make[1]: [CMakeFiles/Makefile2:390: CMakeFiles/ORB_SLAM3.dir/all] Error 2 make: [Makefile:84: all] Error 2

jj-gomez commented 4 years ago

I am not able to reproduce your last error. I have the feeling that is related with your compiler, could you please provide us which compiler and version are you using? (you can find this information in the files generated by CMake, more precisely, at ORB_SLAM3/cmake-build-debug/CMakeFiles/<your_cmake_version>/CMakeCXXCompiler.cmake).

In our experiments, we built ORB-SLAM3 with the following: set(CMAKE_CXX_COMPILER "/usr/bin/c++") set(CMAKE_CXX_COMPILER_ARG1 "") set(CMAKE_CXX_COMPILER_ID "GNU") set(CMAKE_CXX_COMPILER_VERSION "7.5.0") set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "") set(CMAKE_CXX_COMPILER_WRAPPER "") set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "14")

In any case, the error seems to be related with the data structures used in a for loop. Since I cannot reproduce the error, I cannot guarantee the following solves the error but you can give it a try: swap lines 2388, 2389 and 2390 at Optimizer.cc from: for(set<KeyFrame*>::const_iterator sit=spConnections.begin(), send=spConnections.end(); sit!=send; sit++) { const long unsigned int nIDj = (*sit)->mnId;

to: for(auto pKf : spConnections) { const long unsigned int nIDj = pKf->mnId;

belal-ibrahim commented 4 years ago

@jjgr3496 I am trying to build with:

set(CMAKE_CXX_COMPILER "/usr/bin/c++")
set(CMAKE_CXX_COMPILER_ARG1 "")
set(CMAKE_CXX_COMPILER_ID "GNU")
set(CMAKE_CXX_COMPILER_VERSION "9.3.0")
set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "")
set(CMAKE_CXX_COMPILER_WRAPPER "")
set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "14")

### for the Optimizer.cc i have changed the code aforementioned but unfortunately i am still getting the same problem

69%] Linking CXX shared library ../../../Thirdparty/g2o/lib/libg2o.so
[ 69%] Built target g2o
make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:102: CMakeFiles/ORB_SLAM3.dir/src/LoopClosing.cc.o] Error 1
/home/beraru/ORB_SLAM3/src/Tracking.cc: In member function ‘void ORB_SLAM3::Tracking::Track()’:
/home/beraru/ORB_SLAM3/src/Tracking.cc:1155:13: warning: ‘bOK’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 1155 |             if(bOK)
      |             ^~
make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:232: CMakeFiles/ORB_SLAM3.dir/src/Optimizer.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:390: CMakeFiles/ORB_SLAM3.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
jj-gomez commented 4 years ago

I would ask you to try downgrading your compiler version to 7.5.0 and check it the error persists. Anyways I will try to upgrade my compiler in order to replicate the error!

belal-ibrahim commented 4 years ago

@jjgr3496 I downgraded the compiler to 7.5.0 I got this error

/home/beraru/ORB_SLAM3/src/Optimizer.cc:2434:79: error: ‘sit’ was not declared in this scope
             if((nIDi!=pCurKF->mnId || nIDj!=pLoopKF->mnId) && pKF->GetWeight(*sit)<minFeat)
                                                                               ^~~
/home/beraru/ORB_SLAM3/src/Optimizer.cc:2434:79: note: suggested alternative: ‘sin’
             if((nIDi!=pCurKF->mnId || nIDj!=pLoopKF->mnId) && pKF->GetWeight(*sit)<minFeat)
`
`make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:232: CMakeFiles/ORB_SLAM3.dir/src/Optimizer.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:390: CMakeFiles/ORB_SLAM3.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
`
belal-ibrahim commented 4 years ago

what i have made is to replace back for(set<KeyFrame*>::const_iterator sit=spConnections.begin(), send=spConnections.end(); sit!=send; sit++) { const long unsigned int nIDj = (*sit)->mnId;

I got this output without any explicit error! i got this message instead

make[1]: *** [CMakeFiles/Makefile2:390: CMakeFiles/ORB_SLAM3.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
belal-ibrahim commented 4 years ago

Here are my Cmake sets set(CMAKE_CXX_COMPILER "/usr/bin/c++") set(CMAKE_CXX_COMPILER_ARG1 "") set(CMAKE_CXX_COMPILER_ID "GNU") set(CMAKE_CXX_COMPILER_VERSION "7.5.0") set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "") set(CMAKE_CXX_COMPILER_WRAPPER "") set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "14") set(CMAKE_CXX_COMPILE_FEATURES " set(CMAKE_CXX14_COMPILE_FEATURES "

jj-gomez commented 4 years ago

what i have made is to replace back for(set<KeyFrame*>::const_iterator sit=spConnections.begin(), send=spConnections.end(); sit!=send; sit++) { const long unsigned int nIDj = (*sit)->mnId;

I got this output without any explicit error! i got this message instead

make[1]: *** [CMakeFiles/Makefile2:390: CMakeFiles/ORB_SLAM3.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Could you please dump all the output when you build the system to a file and upload here? You can do it as follows:

./build.sh &> log.txt

jj-gomez commented 4 years ago

It looks like you are missing libdc1394 library. Please, install it an make a fresh build of ORB-SLAM3.

belal-ibrahim commented 4 years ago

log.txt

jj-gomez commented 4 years ago

You are still getting the same error (here is the important line of the log: make[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/libdc1394.so', needed by '../lib/libORB_SLAM3.so'. Stop.)

belal-ibrahim commented 4 years ago

log.txt I have opened the directory searching for the package but as i am using ubuntu 20.04 LTS I found the files with other nomination as per image attached: image what i have done; i have changed the code line to libIlmImf.so.6 in all files as per screenshot image

huanglilong commented 4 years ago

fix this build error using this change (ubuntu 20.04, g++9.3.0) image

belal-ibrahim commented 4 years ago

@huanglilong I have edited the file Loopclosing.h as you mentioned and i got this type of errors in the file attached log.txt

domenigoni commented 3 years ago

i have exactly the same errors ...