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

相关推荐
serve the people7 小时前
mac 怎么查看CPU核数
macos
Python私教9 小时前
macOS 中搭建 Flutter 开发环境
flutter·macos
Mac分享吧9 小时前
VMware Fusion虚拟机Mac版 安装Win10系统教程
windows·macos·操作系统·vmware·软件需求·虚拟机·分享软件
空白诗11 小时前
使用 nvm 管理 node 版本:如何在 macOS 和 Windows 上安装使用nvm
windows·macos·node.js·nvm
小白学大数据14 小时前
Snapchat API 访问:Objective-C 实现示例
开发语言·macos·objective-c
救救孩子把1 天前
mac中git操作账号的删除
git·macos
sysin.org1 天前
VMware ESXi 8.0U3b macOS Unlocker & OEM BIOS 2.7 集成网卡驱动和 NVMe 驱动 (集成驱动版)
macos·esxi·bios·unlocker·oem·2.7
yanling20231 天前
Parallels Desktop 20 for Mac中文版发布了?会哪些新功能
macos·虚拟机·pd
不会敲代码的VanGogh1 天前
【iOS】——应用启动流程
macos·ios·objective-c·cocoa
sysin.org1 天前
VMware ESXi 7.0U3q macOS Unlocker 集成驱动版更新 OEM BIOS 2.7 支持 Windows Server 2025
windows·macos·esxi·bios·oem·网卡驱动·nvme驱动