ORB-SLAM3 Compile Error: recipe for target ‘CMakeFiles/ORB_SLAM3.dir/src/LocalMapping.cc.o‘ failed

There is no other prompt for the error encountered when compiling orbslam3. ubuntu18.04

CMakeFiles/ORB_SLAM3.dir/build.make:110: recipe for target 'CMakeFiles/ORB_SLAM3.dir/src/LocalMapping.cc.o' failed
make[2]: *** [CMakeFiles/ORB_SLAM3.dir/src/LocalMapping.cc.o] Error 1
CMakeFiles/Makefile2:289: recipe for target 'CMakeFiles/ORB_SLAM3.dir/all' failed
make[1]: *** [CMakeFiles/ORB_SLAM3.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Solution:

Add the following code to the orb_SLAM3/include/CameraModels/KannalaBrandt8.h

namespace cv 
{ 
template<typename _Tp, int m, int n> static inline Matx<_Tp, m, n> operator/(const Matx<_Tp, m, n>& a, float alpha) 
{
 return Matx<_Tp, m, n>(a, 1.f/alpha, Matx_ScaleOp()); 
} 
}

As shown below

In addition, it is easy to get stuck during compilation. After making in build.sh, remove the multithreading options such as -J4-J

Read More: