Compiling Meshlab

本文档详细介绍了如何编译MeshLab及其所需的各种依赖库,包括Qt4.4、VCG库等。同时还提供了针对不同操作系统的编译指导,如使用GCC、Visual Studio等环境的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

What you need

To compile MeshLab you need a C++ compiling environment, (we regularly compile meshlab under VisualStudio 2005, gcc and xcode) and the following libraries:

  • Qt 4.4 (note that Qt 4.4 are required, Qt versions < 4.4 could not compile). Current version of MeshLab compiles well against Qt 4.4.3.
  • the VCG libraries; http://vcg.sf.net, this library is not distributed by means of easy-to-download packages, but it is only accessible through anonymous svn (svn string: svn co https://vcg.svn.sourceforge.net/svnroot/vcg vcg ). If you get the current version of the VCG library we suggest you to also get the current version of MeshLab. If you want to compile the distributed sources check out from the repository the VCG lib with the same date of the release of MeshLab.
  • MeshLab's source code version 1.2.1. Now you have two different options:
[ edit]

External Dependencies

MeshLab and MeshLab's plugins invokes functions exported by external libraries. The code of all these libraries is normally included in the MeshLab's source code package. You can find it in the folder external in the MeshLab source tree.

  • glew ( http://glew.sourceforge.net/ ), strongly required. You just need the sources (.h and .c), (not the compiled libs), glew is statically compiled into meshlab, so no dynamic libraries are required.
  • lib3ds-1.3.0 ( http://lib3ds.sourceforge.net/ ) This one is needed only for the io_3ds plugin. Without this plugin the 3ds file formats will not be parsed.
  • bzip2-1.0.3 this one is required only for the epoch format import plugins; if you do not have datasets produced with the arc3D web reconstruction service, you do not need this plugin.
  • muParser 1.30 ( http://muparser.sourceforge.net/ ) This library is needed for filter_func plugin.

In order to successfully compile a MeshLab's plugin with external dependency you have before to compile the referred library and put it into the folder meshlab/src/external/lib/YOUR_OS where YOUR_OS is a string related to your operating system and compiler according to QMAKESPEC definition (like for example macx or win32-msvc2005).
Into the folder external a .pro file, external.pro, has been provided to easily compile all the external libraries. To do this you can either:

  • use a Qt-friendly IDE, like Qt Creator, Visual Studio or Eclipse (the last two with the IDE's Qt integration provided by Trolltech)
  • use command line.
qmake -recursive external.pro 
make
 

A note: when we say that a library is needed only for a specific plugin we mean that if you do not have that library you should not try to compile that specific plugin otherwise the compilation of that plugin could fail on that plugin and, depending on your compiling environment, the whole compilation could stop. To avoid the compilation of problematic plugins simply comments the relative line (adding a # at the beginning of the line) in the src/meshlabplugins/meshlabpluginsv12.pro.

[ edit]

Code tree structure

The meshlab sources and the vcg library must be at the same level and the vcg library root should be named 'vcglib'. The external compiled libraries should be placed in a dir named ~/devel/meshlab/external/lib/YOUR_OS (see the above section).
You should have setup your directories in a way that should be similar to the following ones (obviously you are not forced to call your base dir devel or to put it under your home dir):

~/devel/vcglib/vcg/space/ 
~/devel/meshlab/src/meshlab/interfaces.h
~/devel/meshlab/external/lib/YOUR_OS

If you put things in dirs with different relations, you have to manually change the .pro. Please note that if you are a developer that will soon or later submit back its work, it is strongly deprecated that you use your own version of .pro files: use the standard setup.

[ edit]

Compiling

The compiling step depends on the compiling environment. Using GCC (both under linux and using the mingw gcc provided with the free Qt distribution) you should just type, from the devel/meshlab/src directory:

qmake -recursive meshlabv12.pro
make

the devel/meshlab/src directory contains also the meshlab_mini.pro project that contains a much smaller set of the meshlab plugins, easier (no need for lib3ds and bzip) and faster to be compiled.

Under windows the suggested platform is the one formed by the open source version of Qt with the mingw gcc compiler that is kindly included in the open source Qt distribution available from TrollTech.

If you want to use Visual Studio, please buy the commercial version of Qt that offers a nice integration of the Qt tools into the Visual Studio IDE. In that case you simply have to import the top level pro ( ~/devel/meshlab/src/meshlab.pro ) into VisualStudio.

[ edit]

Using Microsoft Visual Studio 8 express edition and QT

It is possible to use the Visual Studio 8 express edition (the one free from MS). Simple steps for the lazy ones:

  • download and install Microsoft Visual Studio 8 express edition
  • download from trolltech QT 4.4.3 , the zip with the sources not the precompiled bin for mingw.
  • unzip it and rename the created folder to c:/Qt/4.4.3 (or something different if you already have installed the qt distribution with mingw.
  • Now open the visual studio console (program files->visual studio 2008-> vs 2008 tools-> vs 2008 command promt). Go to the directory where you unzipped qt and type configure -debug-and-release. Wait a few mins (it compiles qmake and runs it, creating the makefiles for vs2008)
  • type nmake. Wait a few hours (it recompiles the whole Qt).
  • last step: prepare the environment; you have to add to the environment of vs8 command prompt:
set QTDIR=C:/Qtvs/4.4.3
set PATH=C:/Qtvs/4.4.3/bin
set PATH=%PATH%;%SystemRoot%/System32
set QMAKESPEC=win32-msvc2008
  • after that just start that enhanced vs8 command prompt, go in the appropriate dir, type
qmake -tp vc -recursive meshlabv12.pro
  • and magically a solution that contains meshlab and all the plugins will appear.
  • In some cases it could help also to configure visual C++, so it can see always Qt: (tools->options) and add: $(QTDIR)/include to the include directories and $(QTDIR)/lib to the lib directories, but it should not be required (and perhaps a bit dangerous if you upgrade qt).
<think>好的,我现在需要处理用户关于编译过程和编译问题的查询。首先,用户提到了两个引用,引用1和引用2,其中引用2提到了LLVM源码相关的工具,部分用于构建过程中的代码生成。这提示我需要结合编译过程中的代码生成阶段来解释。 用户的需求是了解编译过程或解决编译中的问题。首先,我应该先概述编译的各个阶段,确保每个阶段都有简要说明,并可能提到相关工具,如LLVM中的代码生成器。然后,针对常见编译问题,需要分门别类地列出,比如语法错误、链接错误、优化问题等,并给出解决方法。 接下来,根据系统级指令,需要生成相关问题。我需要确保问题覆盖编译过程的各个阶段、常见错误类型、调试工具以及优化技术等方面。同时,要注意引用用户提供的参考资料,特别是引用2中提到的LLVM工具,可能在代码生成部分引用。 需要检查格式是否符合要求,例如数学表达式是否正确使用$...$,独立公式是否用$$...$$。虽然当前问题可能不涉及太多数学公式,但如果有涉及编译理论中的算法或方程,需要正确格式化。例如,词法分析中的正则表达式可能需要用$...$包裹。 另外,回答必须使用中文,结构清晰,分步骤说明。需要确保每个部分有明确的标题,如编译过程的六个阶段,每个阶段详细说明。然后常见问题及解决方法分点列出,每个问题有例子和解决建议。 最后,生成的相关问题需要与编译过程和问题相关,可能包括阶段细节、工具使用、错误处理、优化技术、LLVM的作用,以及动态链接与静态链接的区别等。确保问题覆盖用户可能感兴趣的各个方面,并引导进一步学习。 现在需要验证是否有遗漏的部分,比如是否每个阶段都有简要说明,是否覆盖了用户提到的编译问题类型,以及是否合理引用了提供的参考资料。同时,确保没有使用任何Markdown格式,完全按照用户的要求用自然的中文组织内容,段落间用空行分隔,代码块使用正确的格式。</think>### 编译过程详解 编译过程是将高级语言代码转换为机器可执行代码的系统性流程,主要分为以下六个阶段: $$词法分析 \rightarrow 语法分析 \rightarrow 语义分析 \rightarrow 中间代码生成 \rightarrow 代码优化 \rightarrow 目标代码生成$$ 1. **词法分析** 扫描源代码生成词法单元(token),例如将`if (x > 0)`分解为关键字`if`、括号`(`、变量`x`、运算符`>`等。正则表达式定义模式:$[a-zA-Z_][a-zA-Z0-9_]*$匹配标识符。 2. **语法分析** 构建抽象语法树(AST),验证结构是否符合语言规范。例如检测括号是否匹配、语句结构是否正确。LLVM使用`clang`前端完成C/C++的语法分析[^2]。 3. **语义分析** 检查类型一致性、作用域等语义规则。如发现`int x = "text"`会报类型不匹配错误。 4. **中间代码生成** 生成与机器无关的中间表示(如LLVM IR),例如: ```llvm %result = add i32 %a, %b ``` 这种中间代码便于后续优化和跨平台支持。 5. **代码优化** 通过算法提升执行效率,例如: - 删除冗余计算:$x = y*2 + y*2 \rightarrow t = y*2; x = t + t$ - 循环展开:将`for (i=0;i<2;i++)`替换为两次循环体 6. **目标代码生成** 转换为特定CPU架构的机器码,涉及寄存器分配(如使用图着色算法)和指令选择。 ### 常见编译问题与解决方法 1. **语法错误** - 现象:缺少分号、括号不匹配 - 示例:`if (x > 0 { ... }` - 解决:检查错误提示的行号,使用IDE语法高亮辅助定位 2. **链接错误** - 类型:`undefined reference to 'func'` - 原因:函数声明未实现或库未链接 - 方案:检查头文件与源文件一致性,确认编译命令包含`-lm`等链接参数 3. **优化引发异常** - 场景:开启`-O3`后程序行为异常 - 分析:可能是编译器激进优化移除了"冗余"代码 - 调试:使用`volatile`关键字保护关键变量,或逐步降低优化级别 4. **内存相关错误** - 检测工具:Valgrind、AddressSanitizer - 典型问题:数组越界(违反$array[N]$的访问边界)、空指针解引用 ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值