windows/linux/mac上编译open3d 0.17.0

写在前面

1、本文内容
windows/linux/mac上编译open3d 0.17.0

2、平台
通过cmake构建项目,跨平台通用
3、转载请注明出处:
https://blog.csdn.net/qq_41102371/article/details/131891820

准备

clone源码,指定0.17.0版本

mkdir open3d170
cd open3d170
git clone -b 0.17.0 https://github.com/isl-org/Open3D.git

编译

windows:

运行下面的命令或者保存至compile.bat运行

cmake -DCMAKE_INSTALL_PREFIX=./open3d170 -DGLIBCXX_USE_CXX11_ABI=OFF ^
-DBUILD_PYTHON_MODULE=OFF -DBUILD_WEBRTC=OFF -DBUILD_EXAMPLES=OFF ^
-DBUILD_ISPC_MODULE=ON -DBUILD_GUI=OFF -S ./Open3D -B ./build
cmake --build ./build --config Release --parallel 8 --target install

如果遇到
error C4996: ‘fmt::v9::detail::arg_mapper::map’: 被声明为已否决
这个问题,找了很多地方包括官方的issue,说了是什么原因但都没有明确易懂的解决方式(截止本文写作时间20230724,若后面官方已出解答,请在评论区留言,谢谢)
https://github.com/isl-org/Open3D/issues/6257

目前暂时可行的解决方法是,在Open3D/CMakeLists.txt添加:

if(WIN32)
    add_compile_options("/wd4996")
endif()

在这里插入图片描述

后面可能再遇到链接库时失败的问题:
ssl.lib(ssl_lib.obj) : error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MD_DynamicRelease”不匹配值“MT_StaticRelease”(OfflineReconstruction.obj 中)

暂时的解决方法只有不编译OfflineReconstruction,找打Open3D/cpp/apps/CMakeLists.txt的最后一行,把它注释掉就不会编译OfflineReconstruction了(不编译OfflineReconstruction不会影响Open3D库的使用)

# open3d_add_app_common(OfflineReconstruction OfflineReconstruction OfflineReconstruction)

在这里插入图片描述

linux/mac:

compile.sh

cmake -DCMAKE_INSTALL_PREFIX=./open3d170_install -DGLIBCXX_USE_CXX11_ABI=OFF \
-DBUILD_PYTHON_MODULE=OFF -DBUILD_WEBRTC=OFF -DBUILD_EXAMPLES=OFF \
-DBUILD_ISPC_MODULE=OFF -DBUILD_GUI=OFF -S ./Open3D -B ./build
cmake --build ./build --config Release --parallel 8 --target install

在mac上,需要提前安装

brew install gfortran
brew install libomp

如果报错 fatal error: ‘experimental/filesystem’ file not found ,参考
https://github.com/isl-org/Open3D/issues/6211
把原来的注释掉,修改为

// #include <experimental/filesystem>
// namespace fs = std::experimental::filesystem;
#include <filesystem>
namespace fs = std::__fs::filesystem;

若在在linux下和ros一起使用,请在编译命令添加

-DGLIBCXX_USE_CXX11_ABI=OFF

注:

不管哪个平台,期间可能会遇到很多库下载超时的错,根据报错信息,下载链接里的文件放到指定路径就行,比如
在这里插入图片描述

–parallel 8表示用8个处理器进行编译,看本机支持多少个,数量越多,编译越快

-DCMAKE_INSTALL_PREFIX=./open3d170_install指定安装目录为open3d170_install,顺利编译完成并且安装成功后,open3d0.17.0会安装到目录open3d170/open3d170_install
在这里插入图片描述

参考

https://github.com/isl-org/Open3D/issues

主要做激光/影像三维重建,配准、分割等常用点云算法,技术交流、咨询可私信

猜你喜欢

转载自blog.csdn.net/qq_41102371/article/details/131891820
今日推荐