MeshLab 2022.02 源码编译教程

目录

前言

编译准备

编译配置

1. 源码下载

2. 路径配置

3. 命令行编译

4. 报错解决

结语


前言

MeshLab是三维立体网格处理软件,为自由软件,首先发布于2005年年底。此软件可显示及处理大量的非结构化网格,并提供编辑、清理、修复及查核等功能,可对模型进行渲染及转换,

(以上内容来自维基百科) 

最近工作中需要用到 MeshLab 中的某个功能,就编译源码研究了一下,本文简单说一下编译教程。

编译准备

本文所用编译工具及编译环境如下:

  1. Windows 10 21H2 x64,Windows SDK 19041
  2. Git 2.36.0
  3. CMake 3.25.1
  4. Qt 5.15.2
  5. Visual Studio 2019

编译配置

编译参考:Build instructions

1. 源码下载

使用 Git 克隆 MeshLab 源码

git clone --recursive https://github.com/cnr-isti-vclab/meshlab

MeshLab 其中还使用到了其他的开源库, “recursive ”参数可以循环克隆所依赖的子仓库。

(如果是下载 MeshLab 源码进行 CMake-gui 进行编译,则会提示很多库找不到,最终虽然也能编译通过,但是因为缺少很多库,功能会有缺失)

2. 路径配置

新建编译文件夹 “build” 和安装文件夹 “install”,本文所使用的编译路径如下:

源码路径:G:/meshlab

编译路径:G:/meshlab/build

安装路径:G:/meshlab/install

ps:

如果电脑本机有 Eigen 库或者编译(安装)有 Eigen 库的相关软件,在后续编译的过程中,Eigen 库的路径可能会导致报错,比如 MITK 。

打开文件 "G:\meshlab\src\vcglib\CMakeLists.txt",修改 37 行和 40 行中的 EIGEN_INCLUDE_DIRS,本文设置如下:

if(VCG_ALLOW_SYSTEM_EIGEN AND EIGEN3_INCLUDE_DIR)
	message(STATUS "- Eigen - using system-provided library")
	set(EIGEN_INCLUDE_DIRS "G:/meshlab/src/vcglib/eigenlib")
elseif(VCG_ALLOW_BUNDLED_EIGEN AND EXISTS "${VCG_EIGEN_DIR}/Eigen/Eigen")
	message(STATUS "- Eigen - using bundled source")
	set(EIGEN_INCLUDE_DIRS "G:/meshlab/src/vcglib/eigenlib")
else()

3. 命令行编译

在开始菜单中的应用列表中,找到文件夹 Visual Studio 2019,使用管理原身份打开 “x64 Native Tool Command Prompt for VS 2019”。

  1. 切换路径至编译路径 “cd /d G:/meshlab/build”
  2. 使用 CMake 编译,命令行中输入一下命令:
    cmake .. -DQt5_DIR=D:/Qt/Qt5.15.2/5.15.2/msvc2019_64/lib/cmake/Qt5 -DQt5Core_DIR=D:/Qt/Qt5.15.2/5.15.2/msvc2019_64/lib/cmake/Qt5Core -DQt5Gui_DIR=D:/Qt/Qt5.15.2/5.15.2/msvc2019_64/lib/cmake/Qt5Gui -DQt5Network_DIR=D:/Qt/Qt5.15.2/5.15.2/msvc2019_64/lib/cmake/Qt5Network -DQt5OpenGL_DIR=D:/Qt/Qt5.15.2/5.15.2/msvc2019_64/lib/cmake/Qt5OpenGL -DQt5Widgets_DIR=D:/Qt/Qt5.15.2/5.15.2/msvc2019_64/lib/cmake/Qt5Widgets -DQt5Xml_DIR=D:/Qt/Qt5.15.2/5.15.2/msvc2019_64/lib/cmake/Qt5Xml -DCMAKE_INSTALL_PREFIX=G:/meshlab/install

    其中前几个是 Qt 模块路径,替换为自己本机对应的 Qt 模块路径即可。
    最后一个是安装路径,替换为自己上一步中设置的安装路径,不设置会默认安装在 C 盘。
    配置完成后回车编译即可,在执行过程中,会下载上文中所提到的缺失的库,等待配置完成即可。

  3. 在编译路径会生成 MeshLab 解决方案,使用 VS 2019 打开 MeshLab.sln,编译选项改为 “Release x64”,直接生成 “ALL_BUILD” 即可,等待编译完成,生成 “INSTALL” 安装。

4. 报错解决

  1. 常量中有换行符
    项目 “meshlab”、“edit_align”、“edit_pickpoints” 三个项目会报该错误,代码中有 Unicode 字符造成的,在三个项目中分别 “右键 -> 属性 -> 配置属性 -> C/C++ -> 命令行”,在其他选项的输入框中最后加上 “/utf-8” 即可。
  2. 运行 meshlab.exe 会报错 “无法定位程序输入点 ...”
    这是 Qt 的依赖问题导致的,手动发布一下就好了。
    新建临时文件夹 temp,复制安装路径下的 meshlab.exe 到该临时文件夹。
    在开始菜单中的应用列表中,找到文件夹 Qt 安装文件夹下的 “Qt 5.15.2 (MSVC 2019 64bit)”命令行,使用命令 “cd /d G:/meshlab/temp" 切换至临时文件夹路径,执行命令 “windeployqt meshlab.exe” 发布程序,会自动复制一些 Qt 依赖文件至该路径。
    最后将多出来的一堆文件,复制到安装路径即可成功运行,使用 VS 运行的话,就复制到 “G:/meshlab/build/src/distrib/Release”

结语

以上就是所有的编译教程,不同的情况编译可能会有不同的情况,欢迎交流。

附录:

MeshLab 编译过程中下载的各个依赖库

-- Downloading Boost from https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.zip
-- Downloading CGAL from https://github.com/CGAL/cgal/releases/download/v5.2.1/CGAL-5.2.1.zip
-- Downloading CGAL from https://www.meshlab.net/data/libs/CGAL-5.2.1.zip
-- Downloading CGAL auxiliary libraries from https://github.com/CGAL/cgal/releases/download/v5.2.1/CGAL-5.2.1-win64-auxiliary-libraries-gmp-mpfr.zip
-- Downloading Levmar from http://users.ics.forth.gr/~lourakis/levmar/levmar-2.6.tgz
-- Downloading Lib3DS from http://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/lib3ds/lib3ds-1.3.0.zip
-- Downloading Lib3DS from https://www.meshlab.net/data/libs/lib3ds-1.3.0.zip
-- Downloading LibIGL from https://github.com/libigl/libigl/archive/refs/tags/v2.4.0.zip
-- Downloading muparser from https://github.com/beltoforion/muparser/archive/refs/tags/v2.3.3-1.zip
-- Downloading muparser from https://www.meshlab.net/data/libs/muparser-2.3.3-1.zip
-- Downloading nexus from https://github.com/cnr-isti-vclab/nexus/archive/refs/heads/master.zip
-- Downloading corto from https://github.com/cnr-isti-vclab/corto/archive/refs/heads/master.zip
-- Downloading OpenCTM from https://sourceforge.net/projects/openctm/files/OpenCTM-1.0.3/OpenCTM-1.0.3-src.zip/download
-- Downloading Qhull from https://github.com/qhull/qhull/archive/refs/tags/2020.2.zip
-- Downloading Structure Synth from https://github.com/alemuntoni/StructureSynth/archive/refs/tags/1.5.1.zip
-- Downloading tinygltf from https://github.com/syoyo/tinygltf/archive/refs/tags/v2.6.3.zip
-- Downloading u3d from https://github.com/alemuntoni/u3d/archive/refs/tags/1.5.1.zip
-- Downloading Xerces-C from https://dlcdn.apache.org//xerces/c/3/sources/xerces-c-3.2.4.zip
-- Downloading LibE57 from https://github.com/asmaloney/libE57Format/archive/refs/tags/v2.3.0.zip
-- Downloading corto from https://github.com/cnr-isti-vclab/corto/archive/refs/heads/master.zip

  • 11
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值