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

相关推荐
mixboot2 天前
macOS Homebrew 安装 Nmap
macos·nmap
Dream-Y.ocean2 天前
告别设备束缚!网易 UU 远程 Mac 被控体验:免费高清 + 多场景丝滑,跨端办公刚需神器
macos
❀͜͡傀儡师2 天前
docker安装mac系统
macos·docker·容器
库奇噜啦呼3 天前
【iOS】多线程学习
macos·ios·cocoa
守城小轩3 天前
Chromium 140 编译指南 macOS 篇:基础环境准备(一)
chrome·macos·chrome devtools·指纹浏览器·浏览器开发·超级浏览器
许泽宇的技术分享3 天前
用 OpenAI Whisper + pyannote.audio 打造“谁在说什么”的全栈语音理解系统
macos·whisper·xcode
游戏开发爱好者83 天前
iOS 商店上架全流程解析 从工程准备到审核通过的系统化实践指南
android·macos·ios·小程序·uni-app·cocoa·iphone
_可乐无糖3 天前
活到老学到老之yt-dlp_macos(二)
macos
hai-chu3 天前
将 Neo4j 安装为 macOS 服务
macos·策略模式·neo4j
远程软件小帮手3 天前
UU远程上线mac被控!如何远程控制 macOS 设备办公?
游戏·macos·智能手机·电脑