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

相关推荐
iBaoxing5 小时前
mac 使用 launchctl 实现每次登录系统时 frpc 就会自动启动
macos
鹏阿鹏5 小时前
【Mac】终端改色-让用户名和主机名有颜色
macos
易我数据恢复大师9 小时前
怎么设置电脑密码?Windows和Mac设置密码的方法
windows·macos·电脑
几维安全16 小时前
如何保护你的 iOS 应用免受逆向工程攻击
macos·objective-c·cocoa
18号房客17 小时前
macOS开发环境配置与应用开发教程(一)
vscode·macos·visualstudio·eclipse·intellij-idea·phpstorm·visual studio
一道微光17 小时前
Mac的M2芯片运行lightgbm报错,其他python包可用,x86_x64架构运行
开发语言·python·macos
CYBEREXP20081 天前
MacOS M3源代码编译Qt6.8.1
c++·qt·macos
SoraLuna2 天前
「Mac畅玩鸿蒙与硬件47」UI互动应用篇24 - 虚拟音乐控制台
开发语言·macos·ui·华为·harmonyos
阿7_QuQ2 天前
怎么在Windows上远程控制Mac电脑?
macos
小路恢弘2 天前
使用Mac自带共享实现远程操作
macos