win10编译meshlab源码

本篇文章主要记录一下我个人学习编译meshlab的过程,关于什么是meshlab这里不做介绍,你可在官网查看。关于如何编译网上资料确实太少,没什么办法只能老实查看人家的readme了,虽然也不太详细。。。
注:本文正在完善中

1. 下载和安装相关的依赖

首先说明一下我的开发环境:windows10,visual studio 2019

  1. 首先从github上获取meshlab的源码。
    大概有70Mb,可能不太稳定。
  2. qt,桌面端开发的框架,直接去官网下载就行,就按照提示安装就行。qt占用空间挺大的,但我们不必全都安装,下边放一下我安装的部分,大概4g左右吧。
    关于版本我下载meshlab的时候官方文档上要求是Qt >= 5.9,尽量最新稳定版吧,最后,安装好记得顺便配置一下qmake环境变量。
    qt安装图片
  3. cmake,可以去官网下载,也可以随便第三方网站吧。
  4. MinGW,安装好且配置完环境变量后,再通过该工具安装make、g++

关于qt的安装和vs的配置,主要参考了:
(1) https://www.jianshu.com/p/37c7f227a01b
(2) https://blog.csdn.net/xiongtiancheng/article/details/80036605

2. 编译

安装好以上所有东西,配置好环境后,下边终于可以开始编译源码啦。
以下几种方法:

  1. 使用qmake
1
2
3
    cd meshlab/src
    qmake
    make
  1. 使用cmake
1
2
3
    cd meshlab
    cmake src/
    make
  1. 使用Qt Creator

    1). Install QtCreator and Qt >= 5.9 with script and xmlpatterns as additional packages;
    2). Open meshlab.pro inside src;
    3). Select your favourite shadow build directory;
    4). Before the build, deactive the QtQuickCompiler option from the qmake call in the project options;
    5). Build meshlab.

3. 错误解决

  1. 执行qmake
    1
    2
    3
    >qmake
    Info: creating stash file D:\Development\meshlab\meshlab-master\src\.qmake.stash
    Project MESSAGE: DISTRIB_DIRECTORY: D:/Development/meshlab/meshlab-master/src/../distrib

    然后执行make后错误

    1
     
  2. 执行cmake后的错误
1
2
3
4
5
6
7
8
9
10
11
12
13
14
CMake Error at CMakeLists.txt:68 (find_package):
  By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5" with any of
  the following names:

    Qt5Config.cmake
    qt5-config.cmake

  Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
  to a directory containing one of the above files.  If "Qt5" provides a
  separate development package or SDK, be sure it has been installed.

4. meshlab源码结构分析

参考:blog.csdn.net/jz_x/article/details/78899050
我们从github上clone的源码有很多东西,我们主要关注源码所在的目录即可,既src目录,下边对src目录下的子目录做出解释(该解释来自其官方文档)

  • external: it contains a series of external libraries needed by several plugins. Some of these libraries are compiled before the compilation of meshlab, if a corresponding systme library is not found and then linked; some other libraries are just included by some plugins.
    包含(meshlab的)数个插件需要的一系列外部库。其中一些库文件在编译meshlab前已被编译过,如果某个相应的系统库文件没有被找到,则链接它。其他一些库文件只被包含在一些插件中。
  • common: a series of utility functions used by MeshLab and its plugins.
    meshlab和它的插件中用到的一系列实用函数
  • meshlab: GUI and core of MeshLab.
    meshlab的GUI和核心(core)
  • meshlabserver: a tool that allows to compute mesh operations through command line
    一个允许通过命令行计算网格操作的工具
  • meshlabplugins: all the plugins that can be added to MeshLab.
    所有可以被添加到meshlab中的插件
  • 下边两个目录是被cmake使用的
    * cmake;
    * templates.
  • 下边还有两个目录包含meshlab的插件,但是已经不再被支持或者是实验性的,并且这些插件也没有在任何meshlab配置中编译:
    * plugins_experimental
    * plugins_unsupported