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

相关推荐
某公司摸鱼前端1 小时前
本地部署DeepSeek教程(Mac版本)
macos·ai编程·ollama·deepseek·deepseek r1
会飞的爱迪生4 小时前
mac安装wireshark
测试工具·macos·wireshark
追光天使1 天前
Mac M1 源码安装FFmpeg,开启enable-gpl 和 lib x264
macos·ffmpeg
会飞的爱迪生1 天前
mac和linux传输文件
linux·运维·macos
数据的世界012 天前
解决.NET程序通过网盘传到Linux和macOS不能运行的问题
linux·运维·服务器·macos
wn5312 天前
【浏览器 - Mac实时调试iOS手机浏览器页面】
前端·macos·ios·智能手机·浏览器
shichen5013 天前
MacOS 如何映射快捷键
macos·mac·策略模式
一丝晨光4 天前
Cocoa和Cocoa Touch是什么语言写成的?什么是Cocoa?编程语言中什么是框架?为什么苹果公司Cocoa类库有不少NS前缀?Swift编程语言?
macos·ios·objective-c·cocoa·swift·uikit·cocoa touch
程序媛-徐师姐4 天前
解决MacOS安装软件时提示“打不开xxx软件,因为Apple无法检查其是否包含恶意软件”的问题
macos·无法检查其是否包含恶意软件·打不开xxx软件
会飞的爱迪生4 天前
mac安装dockerdesktop优化
macos