build g2o viewer on macos

this work is to contribute to SLAM 14 book chapter 11.

build libQGLViewer

  1. build libQGLViewer, as we will use qt5, its corresponding version is 2.7.2
bash 复制代码
git clone https://github.com/GillesDebunne/libQGLViewer.git -b v2.7.2

change QMAKE_MAC_SDK in example/example.pri

bash 复制代码
QMAKE_MAC_SDK = macosx12.3

usexcodebuild -showsdks to show your macos sdk version.

  1. build
bash 复制代码
qmake -spec macx-clang
make -j4 install

QGLViewer.framework will installed at /usr/local/lib/QGLViewer.framework

  1. copy folder QGLViewer.framework to /Library/Frameworks

build g2o

  1. set up flag in cmake file in apps, make sure the two flags are true while configuring
bash 复制代码
add_subdirectory(g2o_cli)

if (G2O_BUILD_SLAM2D_TYPES AND G2O_BUILD_SLAM3D_TYPES)
  add_subdirectory(g2o_simulator)
endif()


message("QGLVIEWER_FOUND:" ${QGLVIEWER_FOUND})
message("Qt5_FOUND:" ${Qt5_FOUND})


if(QGLVIEWER_FOUND AND Qt5_FOUND)
  add_subdirectory(g2o_viewer)
endif()

if(G2O_BUILD_LINKED_APPS AND G2O_BUILD_SBA_TYPES AND G2O_BUILD_SCLAM2D_TYPES)
  add_subdirectory(linked_binaries)
endif()
  1. use cmake or cmake-gui to configure
bash 复制代码
Compiling on OSX
Found AMD headers in: /usr/local/include
Found AMD library: /usr/local/lib/libamd.dylib
Found CAMD headers in: /usr/local/include
Found CAMD library: /usr/local/lib/libcamd.dylib
Found CCOLAMD headers in: /usr/local/include
Found CCOLAMD library: /usr/local/lib/libccolamd.dylib
Found CHOLMOD headers in: /usr/local/include
Found CHOLMOD library: /usr/local/lib/libcholmod.dylib
Found COLAMD headers in: /usr/local/include
Found COLAMD library: /usr/local/lib/libcolamd.dylib
Found SPQR headers in: /usr/local/include
Found SPQR library: /usr/local/lib/libspqr.dylib
Found Config headers in: /usr/local/include
Found Config library: /usr/local/lib/libsuitesparseconfig.dylib
Found Intel Thread Building Blocks (TBB) library (2021.10 / ) include location: . Assuming SuiteSparseQR was compiled with TBB.
Could not find librt, but found SuiteSparse_config, assuming that SuiteSparse was compiled without timing.
Enable support for Cholmod
Building LGPL code as a shared library
Enable support for CSparse
Compiling with OpenGL support
Compiling SLAM 3D types
Compiling built in types slam2d slam2d (addons) data sclam2d slam3d slam3d (addons) sba icp sim3
Compiling g2o apps
Compiling g2o examples
Compiling with Clang
QGLVIEWER_FOUND:TRUE
Qt5_FOUND:1
Generating position independent code for slam2d because Qt5 was built with -reduce-relocations
Configuring done (1.3s)

manually set QGLVIEWER_INCLUDE_DIR

  1. make
bash 复制代码
make -j4
[  1%] Built target opengl_helper
[  2%] Built target freeglut_minimal
[  4%] Built target parser_library
[  7%] Built target stuff
[  8%] Built target interface_library
[  9%] Built target csparse_extension
[ 18%] Built target core
[ 19%] Built target solver_pcg
[ 20%] Built target g2o_cli_library
[ 20%] Built target solver_dense
[ 21%] Built target solver_eigen
[ 26%] Built target types_slam2d
[ 26%] Built target solver_structure_only
[ 32%] Built target types_slam3d
[ 33%] Built target solver_csparse
[ 34%] Built target solver_cholmod
[ 35%] Built target circle_fit
[ 36%] Built target curve_fit
[ 37%] Built target polynomial_fit
[ 38%] Built target static_dynamic_function_fit
[ 39%] Built target bal_example
[ 40%] Built target static_target
[ 41%] Built target constant_velocity_target
[ 41%] Built target create_sphere
[ 42%] Built target g2o_anonymize_observations_application
[ 44%] Built target g2o_interactive_library
[ 47%] Built target tutorial_slam2d_library
[ 47%] Building CXX object g2o/examples/slam2d/CMakeFiles/slam2d_g2o.dir/main_window.cpp.o
[ 48%] Building CXX object g2o/examples/slam2d/CMakeFiles/slam2d_g2o.dir/slam2d_viewer.cpp.o
[ 49%] Built target simple_optimize
[ 49%] Building CXX object g2o/examples/slam2d/CMakeFiles/slam2d_g2o.dir/slam2d_g2o.cpp.o
[ 51%] Built target g2o_hierarchical_library
[ 52%] Built target g2o_cli_application
[ 52%] Building CXX object g2o/examples/slam2d/CMakeFiles/slam2d_g2o.dir/moc_main_window.cpp.o
[ 56%] Built target types_slam2d_addons
[ 60%] Built target types_slam3d_addons
[ 61%] Building CXX object g2o/apps/g2o_viewer/CMakeFiles/viewer_library.dir/g2o_qglviewer.cpp.o
[ 64%] Built target types_data
[ 66%] Built target types_sclam2d
[ 66%] Building CXX object g2o/apps/g2o_viewer/CMakeFiles/viewer_library.dir/main_window.cpp.o
[ 73%] Built target types_sba
[ 73%] Building CXX object g2o/apps/g2o_viewer/CMakeFiles/viewer_library.dir/stream_redirect.cpp.o
[ 74%] Building CXX object g2o/apps/g2o_viewer/CMakeFiles/viewer_library.dir/gui_hyper_graph_action.cpp.o
[ 75%] Built target solver_slam2d_linear
[ 75%] Building CXX object g2o/apps/g2o_viewer/CMakeFiles/viewer_library.dir/properties_widget.cpp.o
[ 75%] Building CXX object g2o/apps/g2o_viewer/CMakeFiles/viewer_library.dir/viewer_properties_widget.cpp.o
[ 76%] Building CXX object g2o/apps/g2o_viewer/CMakeFiles/viewer_library.dir/run_g2o_viewer.cpp.o
[ 77%] Built target tutorial_slam2d
[ 77%] Building CXX object g2o/apps/g2o_viewer/CMakeFiles/viewer_library.dir/moc_main_window.cpp.o
[ 78%] Built target calibration_odom_laser_library
[ 78%] Building CXX object g2o/apps/g2o_viewer/CMakeFiles/viewer_library.dir/moc_properties_widget.cpp.o
[ 79%] Built target ba_demo
[ 79%] Built target ba_anchored_inverse_depth_demo
[ 80%] Built target convert_sba_slam3d
[ 81%] Built target simulator_3d_line
[ 81%] Built target simulator_3d_plane
[ 81%] Built target g2o_online_application
[ 81%] Built target g2o_incremental_library
[ 81%] Built target convertSegmentLine_application
[ 82%] Built target g2o_hierarchical_application
[ 82%] Built target types_icp
[ 83%] Built target types_sim3
[ 89%] Built target g2o_simulator_library
[ 90%] Built target sclam_odom_laser
[ 90%] Built target sclam_pure_calibration
[ 91%] Built target sclam_laser_calib
[ 91%] Built target gicp_demo
[ 92%] Built target gicp_sba_demo
[ 93%] Linking CXX shared library ../../../lib/libg2o_viewer.dylib
[ 93%] Built target sba_demo
[ 93%] Built target optimize_sphere_by_sim3
[ 94%] Built target g2o_incremental_application
[ 95%] Built target g2o_simulator2d_application
[ 96%] Built target g2o_simulator3d_application
[ 97%] Built target viewer_library
[ 97%] Building CXX object g2o/apps/g2o_viewer/CMakeFiles/g2o_viewer.dir/g2o_viewer.cpp.o
[ 98%] Linking CXX executable ../../../bin/slam2d_g2o
[ 99%] Built target slam2d_g2o
[100%] Linking CXX executable ../../../bin/g2o_viewer
[100%] Built target g2o_viewer

you might encounter confict if you have qt6 on your pc. just run

bash 复制代码
brew unlink qt
brew link qt5
  1. finally, run the viewer

https://blog.csdn.net/fujianfafu/article/details/51902874

相关推荐
HelloMagina1 小时前
Xcode控制台“po“错误:表达式解析失败
ide·macos·xcode
Java小白笔记2 小时前
Mac中安装OhMyZsh
macos
DisonTangor2 小时前
拆解测试显示Mac Mini (2024)固态硬盘并未锁定 互换硬盘后仍可使用
macos
狂奔solar3 小时前
分享个好玩的,在k8s上部署web版macos
前端·macos·kubernetes
代码猪猪傻瓜coding3 小时前
macos 搭建自己的git pages
macos
PC端游爱好者10 小时前
研究生如何远控实验室电脑?远程办公功能使用教程
macos·智能手机·电脑
SoraLuna11 小时前
「Mac玩转仓颉内测版12」PTA刷题篇3 - L1-003 个位数统计
算法·macos·cangjie
SoraLuna20 小时前
「Mac玩转仓颉内测版10」PTA刷题篇1 - L1-001 Hello World
算法·macos·cangjie
_可乐无糖1 天前
mac终端使用pytest执行iOS UI自动化测试方法
macos·pytest
后端常规开发人员1 天前
在 Mac 上使用 Docker 安装宝塔并部署 LNMP 环境
macos·docker·容器·宝塔