• 这篇文章主要记录了更新Mitsuba依赖, 以及在VS2019, Python3.9等等比较现代的环境下编译的过程.
  • 为了编译Mitsuba, 我写了一个CMakeLists专门用来下载和编译依赖; 源码也为了适应新的依赖做了一点修改. 修改后的版本已经放在了Github上, 按照 Readme 应当是能够直接编译的. (有问题欢迎issue, 我会尽量回复)
  • 文章之前记录的是SCons编译Mitsuba, 现在CMake版本已经完成, 并且这里记录的内容也有助于CMake编译时候Debug

Mitsuba

  • Mitsuba是面向科研的离线渲染框架, 虽然现在已经有了Mitsuba2, 但 Mitsuba 0.6.0 还是因为功能齐全/简单好用, 经常在各种Siggraph论文里被用于实现算法.
  • 用Mitsuba最麻烦的一点是年久失修, 这里指的是编译的工具链过时. Mitsuba的代码质量非常优秀, 只是因为太久没有更新维护导致各种依赖跟不上现在的版本.
  • 编译思路主要是自行编译依赖. 如果手动下载, 配置和编译依赖肯定会很麻烦. 但是幸好我们有CMake, 只要几行代码就可以自动编译一个库, 编译完还能将依赖拷贝到对应的地方.

环境/准备工作

  • 这里所指的环境是必须手动去官网准备的, 因为这些软件安装比较麻烦, 个人没办法简单地用脚本完成环境配置, 所以需要手动下载和安装
  • 注意这里的环境只要大版本相同即可, 小版本是我的个人选择

  • Visual Studio 2019 (MSVC/cl)
  • CMake
  • Mitsuba源码(分支 scons-python3): git clone https://github.com/mitsuba-renderer/mitsuba.git --branch scons-python3

  • Python 3.9: (更新/更老的Python3都可以, 个人用的是3.9)
  • Scons 4.3.1: pip install SCons
  • Qt 5.15: 可以只选择最新版本的Qt5, 需要安装与VS版本相同的64位版本(例如VS2019, 64bit)

依赖

这是整个编译过程中最麻烦, 花费时间最多的部分. Mitsuba官方提供了编译好的依赖, 但就是因为他们是编译好的, 有些依赖在VS2019下链接不上. 所以需要自行把Mitsuba的依赖进行更新.

  • 注意: 这一部分的所有命令行操作请在 64 位的 VS Command Prompt 下执行, 否则cl.exe, lib.exe等等可能会找不到命令

通过CMake下载和编译依赖

我写了一个CMake的脚本, 将Mitsuba用到的依赖都更新到了当前最新(?)的版本, 脚本可在Github上自取. 依赖编译的时间会比较长, 需要耐心等待.

在使用之前, 需要做部分说明

  • 再次强调, 所有命令行操作请在 64 位的 VS Command Prompt 下执行
  • 请确保网络状况良好, 能够下载和克隆外网/github上的内容. 代理请开启全局代理
  • CMakeLists.txt中有部分内容需要自行修改:
    • Line8: set(COMPILE_THREAD 20) 这里设置的是编译依赖时并行的线程数, 20表示使用20个线程, 设置为本机CPU核数即可.
    • Line9 & Line10: 这里设置的是下载时的代理, 如果你不需要, 或者你不知道这是什么意思, 请将这两行注释掉.
  • 如果你的网络状况不好, 没有办法通过CMake下载, 或者下载下来的东西是损坏的/是0KB的, 那请参考后面"依赖列表"部分, 手动下载/克隆依赖, 然后放到dependencies/Downloads中. 完成下载后再接着下面的步骤运行

具体使用的步骤是这样的:

  • 在Mitsuba项目下新建dependencies文件夹, 然后将CMakeLists.txt复制进去
  • 命令行进入dependencies目录
  • 运行cmake ./

经过漫长的编译后, 依赖就配置完成了. 如果你不确定有没有完成, 那没有关系, 也可以直接跳到"Mitsuba编译"部分. 发生依赖错误的时候在回来, 然后将CMakeLists.txt中其他的依赖配置代码注释掉, 只留下没有配置成功的依赖, 然后再次运行cmake ./.

依赖列表

  • 下面是CMakeLists.txt中包含的依赖列表, 如果你的网络是在太差, 或者不知道怎么让CMake通过代理下载/克隆依赖, 可以参考下面的列表, 手动将需要下载的内容下载好.
  • 这里面所有需要下载/克隆的内容, 无论是压缩包还是文件, 还是文件夹, 都放在dependencies/Downloads下即可
  • 下面的列表"路径/文件名"一列中, 带"/"表示这是文件夹, 否则是文件
依赖 路径/文件名 克隆命令/下载地址
zlib zlib/ git clone --recurse-submodules https://github.com/madler/zlib.git
OpenEXR openexr/ git clone --recurse-submodules https://github.com/AcademySoftwareFoundation/openexr.git
libjpeg-turbo libjpeg/ git clone --recurse-submodules https://github.com/libjpeg-turbo/libjpeg-turbo.git
libpng libpng/ git clone --recurse-submodules https://github.com/glennrp/libpng.git
boost boost/ git clone --recurse-submodules --depth=1 --branch=boost-1.77.0 https://github.com/boostorg/boost.git
xerces-c xerces-c/ git clone --recurse-submodules https://github.com/apache/xerces-c.git
glew glew-2.2.0-win32.zip https://github.com/nigels-com/glew/releases/download/glew-2.2.0/glew-2.2.0-win32.zip
half half-2.2.0.zip https://iweb.dl.sourceforge.net/project/half/half/2.2.0/half-2.2.0.zip
glext glext.h https://www.khronos.org/registry/OpenGL/api/GL/glext.h
khr khrplatform.h https://www.khronos.org/registry/EGL/api/KHR/khrplatform.h
FFTW fftw-3.3.5-dll64.zip https://fftw.org/pub/fftw/fftw-3.3.5-dll64.zip

源码编译

  • 以上的依赖已经完成了编译和配置后, 依赖的路径是这样的

    • dependencies/include: 包含*.h, *.hpp等头文件
    • dependencies/lib: 包含*.lib等库文件
    • dependencies/bin: 包含*.dll, *.bin等可执行文件

CMake编译

  • 用CMake编译最麻烦的地方还是需要自己手动写多个CMakeLists.txt. Mitsuba中包括了很多个不同的插件, 所以最后整个工程中项目非常多. 目前个人的Github上已经完成了CMake的编译~

具体步骤是这样的:

  1. 项目根目录下新建文件夹cbuild, 注意不是在build下编译(因为那里已经有多个SCons编译相关的文件, 直接编译在那里会把很多文件混在一起).
  2. 用CMakeGUI编译, 或用命令行进入cbuild, 然后运行cmake ..
  3. 打开工程, 编译整个Solution.
  4. 完成, 可以按正常的VS项目开发/Debug了.

SCons编译

修改配置文件

  • Mitsuba依靠SCons进行编译, 由于Mitsuba原始的SCons是基于Python2的, 而且Mitsuba的依赖也是我们自己编译的最新版本, 所以需要修改配置文件.
  • 这里的部分配置会涉及到依赖的版本, 如果你的环境/依赖与我不同, 请自行做微调(例如v142调成v141, Qt的安装目录做些修改之类的). 最关键的就是, 要把你的依赖名称/目录写正确, 让编译器能够找到这个依赖.
config.py
  • SCons需要读取项目根目录下的config.py作为配置, Mitsuba官方在build/下提供了几个模板, 我们基于这些模板来做修改: 复制build/config-win64-msvc2017.pyconfig.py

    • BASELIB: BASELIB中的Half现在仅包含头文件, 所以可以去掉Half
    • OEXRINCLUDE: OpenEXR现在将依赖目录分为了两个, 需要都添加进去OEXRINCLUDE = ['#dependencies/include/OpenEXR', '#dependencies/include/Imath']
    • OEXRLIB: OpenEXR的库已经更名, 现在应当为: OEXRLIB = ['OpenEXR-3_1', 'IlmThread-3_1', 'Iex-3_1', 'zlib']
  • BOOSTINCLUDE: 源文件中没有这一项, 但是我们的boost includ目录有些不一样, 所以需要加上: BOOSTINCLUDE = ['#dependencies/include/boost-1_77']
  • BOOSTLIB: boost system现在不会被编译为库了, 所以需要移除. 另外boost是我们自行编译的, 版本号需要更新: BOOSTLIB = ['libboost_filesystem-vc142-mt-x64-1_77', 'libboost_thread-vc142-mt-x64-1_77']
  • XERCESLIB = ['xerces-c_4']我们用的是版本4
  • GLLIB: 将其中的glew32mx修改为glew32
  • PYTHON39LIB: 这里需要填入两项内容, 第一是boost的python库, 第二是python提供的库: PYTHON39LIB = ['boost_python39-vc142-mt-x64-1_77', 'C:/Program Files/Python39/libs/python39']
  • PYTHON39INCLUDE: 填入python提供的头文件目录: PYTHON39INCLUDE = ['C:/Program Files/Python39/include']
  • QTINCLUDE = ['C:/Qt/5.15.2/msvc2019_64/include']
  • QTDIR = 'C:/Qt/5.15.2/msvc2019_64'
SConscript
  • SConstruct中可能会用到has_key, 这是当前不支持的语法, 所以会发生报错:
AttributeError: 'SConsEnvironment' object has no attribute 'has_key':File "H:\mitsuba\SConstruct", line 34:build('src/libcore/SConscript')File "H:\mitsuba\SConstruct", line 28:return SConscript(scriptFile, exports,File "c:\users\****************************************************\SConscript.py", line 660:return method(*args, **kw)File "c:\users\****************************************************\SConscript.py", line 597:return _SConscript(self.fs, *files, **subst_kw)File "c:\users\****************************************************\SConscript.py", line 285:exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)File "H:\mitsuba\src\libcore\SConscript", line 5:if coreEnv.has_key('OEXRLIBDIR'):
  • 解决方法: 将has_key替换为in即可, 例如: coreEnv.has_key('OEXRLIBDIR')替换为'OEXRLIBDIR' in coreEnv
  • 存在多个SConstruct文件, 这些文件都需要修改
build/SConscript.configure
  • 34行的Python版本需要自行添加
python_versions = ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9"] # 添加 "3.8", "3.9"
  • 建议将检查Qt5的异常捕获关闭, 因为我们需要编译Gui
# Line 96
env = Environment(options=vars, ENV = os.environ, tools=['default', 'qt5'], toolpath=['#data/scons'])
print('Checking for Qt 5.x... yes')
hasQt = True
# try:
#         env = Environment(options=vars, ENV = os.environ, tools=['default', 'qt5'], toolpath=['#data/scons'])
#         print('Checking for Qt 5.x... yes')
#         hasQt = True
# except Exception:
#         env = Environment(options=vars, ENV = os.environ, tools=['default'], toolpath=['#data/scons'])
#         print('Unable to detect a Qt installation -- not building the GUI!')
#         hasQt = False
  • 194行的OpenEXR检查需要更新路径, 不知道为什么使用"ImfRgba.h"始终返回False, 这里用'openexr.h'代替
if not conf.CheckCXXHeader('openexr.h'): # conf.CheckCXXHeader('ImfRgba.h'):print('OpenEXR is missing (install libopenexr-dev for OpenEXR I/O support)')
else:env.Append(CPPDEFINES = [['MTS_HAS_OPENEXR', 1]] )
data/scons/qt5.py
  • 这是用来检查Qt5的, 但是SCons.Warnings.Warning会抛出异常, 所以需要这样修改:
# Line 47
# class ToolQtWarning(SCons.Warnings.Warning):
class ToolQtWarning():passclass GeneratedMocFileNotIncluded(ToolQtWarning):passclass QtdirNotFound(ToolQtWarning):pass# SCons.Warnings.enableWarningClass(ToolQtWarning)
build/SConscript.install
  • 这一部分需要修改的内容有点多, 不一一赘述. 但是修改的地方都会把原有内容注释掉
  • 这部分主要负责将依赖拷贝至编译后的文件夹, 需要将依赖的版本, 路径等等写正确
if sys.platform == 'win32':for plugin in plugins:if '.dll' in plugin.__str__():installTargets += env.Install(os.path.join(distDir, 'plugins'), plugin)boost_version = '1_77'compilerType = 'vc142' # 'vc141'archType = 'x64' if 'WIN64' in env['CXXFLAGS'] else 'i386'dllprefix = '#dependencies/bin' # '#dependencies/lib'if hasCollada:install(distDir, ['converter/mtsimport.exe'])sdkDir = os.path.join(distDir, "sdk")sdkLibDir = os.path.join(sdkDir, "lib")install(distDir, ['mitsuba/mitsuba.exe', 'mitsuba/mtssrv.exe', 'mitsuba/mtsutil.exe'])install(distDir, ['libcore/libmitsuba-core.dll', 'libhw/libmitsuba-hw.dll','librender/libmitsuba-render.dll', 'libbidir/libmitsuba-bidir.dll'])install(sdkLibDir, ['libcore/mitsuba-core.lib', 'libhw/mitsuba-hw.lib','librender/mitsuba-render.lib', 'libbidir/mitsuba-bidir.lib'])for entry in os.walk(os.path.join(basePath, "include")):includeDir = entry[0][len(basePath)+1:]installTargets += env.Install(os.path.join(sdkDir, includeDir),[ ('#' + os.path.join(includeDir, fname)) for fname in entry[2] ])for ver in hasPython:installAs(os.path.join(distDir, 'python/'+ver+'/mitsuba.pyd'), 'libpython/mitsuba_python' + ver + '.dll')install(distDir, ['Iex-3_1.dll','IlmThread-3_1.dll', 'Imath-3_2.dll','OpenEXR-3_1.dll','zlib.dll','libpng16.dll', 'jpeg62.dll', 'xerces-c_4_0.dll', 'glew32.dll', 'libfftw3-3.dll'],prefix=dllprefix)# install(distDir, ['Iex.dll', 'Half.dll','IlmThread.dll', 'Imath.dll','IlmImf.dll','zlib1.dll',# 'libpng16.dll', 'jpeg.dll', 'xerces-c_3_1.dll', 'glew32mx.dll', 'libfftw3-3.dll'],# prefix=dllprefix)for boostlib in ['python39', 'filesystem', 'chrono', 'thread']: # for boostlib in ['python27', 'python35', 'python36', 'system', 'filesystem', 'chrono', 'thread']:if 'WIN64' in env['CXXFLAGS']:install(distDir, ['boost_%s-%s-mt-x64-%s.dll' % (boostlib, compilerType, boost_version)], dllprefix)else:install(distDir, ['boost_%s-%s-mt-%s.dll' % (boostlib, compilerType, boost_version)], dllprefix) # install(distDir, ['boost_%s-%s-mt-1_64.dll' % (boostlib, compilerType)], dllprefix)installTargets += env.Install(distDir, '#data/windows/README.txt')if hasQt:install(distDir, ['mtsgui/mtsgui.exe'])install(distDir, ['Qt5Core.dll', 'Qt5Gui.dll', 'Qt5Widgets.dll', 'Qt5Xml.dll','Qt5Network.dll', 'Qt5OpenGL.dll', 'Qt5XmlPatterns.dll'], prefix = env['QT5_BINPATH'])# env['QT5_LIBPATH'])QT5_PLUGIN_PATH = os.path.join(os.path.join('$QTDIR', 'plugins'), 'platforms')DIST_PLUGIN_PATH = os.path.join(os.path.join(distDir, 'plugins'), 'platforms')install(DIST_PLUGIN_PATH, ['qdirect2d.dll', 'qdirect2dd.dll','qminimal.dll', 'qminimald.dll', 'qoffscreen.dll', 'qoffscreend.dll','qwindows.dll', 'qwindowsd.dll'], prefix=QT5_PLUGIN_PATH)
dependencies/version
  • Mitsuba在编译的时候需要检查dependencies/version这个文件
  • dependencies文件夹下新建一个文本文件, 取名verison, 写入内容0.6.0
  • 或者直接参考"依赖列表"部分, 从github上下载

编译Mitsuba源码

  • 编译时请在 64 位的 VS Command Prompt 下进行操作
  • 编译的步骤很简单, 直接在项目根目录下运行scons即可
  • 编译时还会遇到编译/链接错误, 下面记录了个人遇到的错误, 发生的原因以及修改办法

编译错误

  • 如果你使用的是我的Github上修改的版本, 那么可以跳过这部分
  • 编译时遇到的问题也许能够在这里找到答案
  • 依赖更新后还需要对Mitsuba的源码做一些修改, 以适应新的版本, 下面是修改的记录(可能不全, 但是基本的Error都已经记录了下来, 并且说明了怎么进行修改)
  • 建议使用VSCode进行内容查找

src\libcore\bitmap.cpp(100): error C2039: 'Int64': is not a member of 'Imf'

cl /Fobuild\release\libcore\bitmap.obj /c src\libcore\bitmap.cpp /nologo /Oi /Ot /Oy /Ob1 /Gs /GF /Gy /fp:fast /D WIN32 /D WIN64 /W3 /EHsc /GS- /GL /MD /D MTS_DEBUG /D SINGLE_PRECISION /D SPECTRUM_SAMPLES=3 /D MTS_SSE /D MTS_HAS_COHERENT_RT /D _CONSOLE /D NDEBUG /D OPENEXR_DLL /openmp /nologo /DMTS_BUILD_MODULE=MTS_MODULE_CORE /DMTS_HAS_LIBPNG=1 /DMTS_HAS_LIBJPEG=1 /DMTS_HAS_OPENEXR=1 /DMTS_HAS_FFTW=1 /Idependencies\include\OpenEXR /Idependencies\include\Imath /Idependencies\include\OpenEXR /Idependencies\include\Imath /Idependencies\include\boost-1_77 /Iinclude /Idependencies\include
bitmap.cpp
src\libcore\bitmap.cpp(100): error C2039: 'Int64': is not a member of 'Imf'
src\libcore\bitmap.cpp(100): error C3646: 'tellg': unknown override specifier
src\libcore\bitmap.cpp(100): error C2059: syntax error: '('
src\libcore\bitmap.cpp(100): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
src\libcore\bitmap.cpp(104): error C2039: 'Int64': is not a member of 'Imf'
src\libcore\bitmap.cpp(104): error C2061: syntax error: identifier 'Int64'
src\libcore\bitmap.cpp(105): error C2065: 'pos': undeclared identifier
src\libcore\bitmap.cpp(124): error C2039: 'Int64': is not a member of 'Imf'
src\libcore\bitmap.cpp(124): error C3646: 'tellp': unknown override specifier
src\libcore\bitmap.cpp(124): error C2059: syntax error: '('
src\libcore\bitmap.cpp(124): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
src\libcore\bitmap.cpp(128): error C2039: 'Int64': is not a member of 'Imf'
src\libcore\bitmap.cpp(128): error C2061: syntax error: identifier 'Int64'
src\libcore\bitmap.cpp(129): error C2065: 'pos': undeclared identifier
src\libcore\bitmap.cpp(2781): error C2259: 'mitsuba::EXRIStream': cannot instantiate abstract class
src\libcore\bitmap.cpp(2781): error C2259: 'mitsuba::EXRIStream': cannot instantiate abstract class
  • 原因: OpenEXR更新后, 原有的Imf::Int64被替换为C++自带的64位整数int64_t或者uint64_t, 这里需要将报错的地方进行相应的替换. 另外, 替换的时候注意要根据父类的函数返回值和参数类型来替换
uint64_t tellg() { // Imf::Int64 tellg() { // Line 100
void seekg(uint64_t pos) { // void seekg(Imf::Int64 pos) { // Line 104
uint64_t tellp() { // Imf::Int64 tellp() { // Line 124
void seekp(uint64_t pos) { // void seekp(Imf::Int64 pos) { // Line 128

Imf_3_1::FrameBuffer

  • src\libcore\bitmap.cpp(3013): error C2079: 'frameBuffer' uses undefined class 'Imf_3_1::FrameBuffer'
src\libcore\bitmap.cpp(3013): error C2079: 'frameBuffer' uses undefined class 'Imf_3_1::FrameBuffer'
src\libcore\bitmap.cpp(3025): error C2039: 'Slice': is not a member of 'Imf'
src\libcore\bitmap.cpp(3025): error C3861: 'Slice': identifier not found
src\libcore\bitmap.cpp(3033): error C2039: 'Slice': is not a member of 'Imf'
src\libcore\bitmap.cpp(3033): error C3861: 'Slice': identifier not found
src\libcore\bitmap.cpp(3042): error C2664: 'void Imf_3_1::InputFile::setFrameBuffer(const Imf_3_1::FrameBuffer &)': cannot convert argument 1 from 'int' to 'const Imf_3_1::FrameBuffer &'
src\libcore\bitmap.cpp(3298): error C2079: 'frameBuffer' uses undefined class 'Imf_3_1::FrameBuffer'
src\libcore\bitmap.cpp(3302): error C2039: 'Slice': is not a member of 'Imf'
src\libcore\bitmap.cpp(3302): error C3861: 'Slice': identifier not found
src\libcore\bitmap.cpp(3306): error C2039: 'Slice': is not a member of 'Imf'
src\libcore\bitmap.cpp(3306): error C3861: 'Slice': identifier not found
src\libcore\bitmap.cpp(3308): error C2039: 'Slice': is not a member of 'Imf'
src\libcore\bitmap.cpp(3308): error C3861: 'Slice': identifier not found
src\libcore\bitmap.cpp(3309): error C2039: 'Slice': is not a member of 'Imf'
src\libcore\bitmap.cpp(3309): error C3861: 'Slice': identifier not found
src\libcore\bitmap.cpp(3310): error C2039: 'Slice': is not a member of 'Imf'
src\libcore\bitmap.cpp(3310): error C3861: 'Slice': identifier not found
src\libcore\bitmap.cpp(3315): error C2039: 'Slice': is not a member of 'Imf'
src\libcore\bitmap.cpp(3315): error C3861: 'Slice': identifier not found
src\libcore\bitmap.cpp(3319): error C2039: 'Slice': is not a member of 'Imf'
src\libcore\bitmap.cpp(3319): error C3861: 'Slice': identifier not found
src\libcore\bitmap.cpp(3326): error C2039: 'Slice': is not a member of 'Imf'
src\libcore\bitmap.cpp(3326): error C3861: 'Slice': identifier not found
src\libcore\bitmap.cpp(3330): error C2664: 'void Imf_3_1::OutputFile::setFrameBuffer(const Imf_3_1::FrameBuffer &)': cannot convert argument 1 from 'int' to 'const Imf_3_1::FrameBuffer &'
  • include文件没有加上, 在include/mitsuba/core/half.h中, #include<half.h>后面加上#include <ImfFrameBuffer.h>即可

unresolved externals imath_half_to_float_table

  • build\release\libcore\libmitsuba-core.dll : fatal error LNK1120: 1 unresolved externals imath_half_to_float_table
  • 应该是有个依赖库没有链接上, 但是OpenEXR 3.1开始支持了基于位运算的half精度, 所以直接在include/mitsuba/core/half.h中, #include<half.h>前面加一个宏#define IMATH_HALF_NO_LOOKUP_TABLE就可以了

‘_vsnprintf’: is not a member of ‘std’

cl /Fobuild\release\libcore\thread.obj /c src\libcore\thread.cpp /nologo /Oi /Ot /Oy /Ob1 /Gs /GF /Gy /fp:fast /D WIN32 /D WIN64 /W3 /EHsc /GS- /GL /MD /D MTS_DEBUG /D SINGLE_PRECISION /D SPECTRUM_SAMPLES=3 /D MTS_SSE /D MTS_HAS_COHERENT_RT /D _CONSOLE /D NDEBUG /D OPENEXR_DLL /openmp /nologo /DMTS_BUILD_MODULE=MTS_MODULE_CORE /DMTS_HAS_LIBPNG=1 /DMTS_HAS_LIBJPEG=1 /Idependencies\include\openexr /Idependencies\include\openexr /Idependencies\include\boost-1_77 /Iinclude /Idependencies\include
thread.cpp
dependencies\include\boost-1_77\boost/system/detail/snprintf.hpp(57): error C2039: '_vsnprintf': is not a member of 'std'
  • 原因: Mitsuba中platform.hvsnprintf进行了宏替换, 新版本的boost/MSVC已经不需要这样做了, 这里将用宏定义#if (defined(_MSC_VER) && _MSC_VER < 1900)把替换的内容注释掉.
// include/mitsuba/core/platform.h, Line 215
#if (defined(_MSC_VER) && _MSC_VER < 1900)
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#endif

SAXParser相关语法错误

情况1: 命名空间相关错误
   util.cppinclude\mitsuba/render/scenehandler.h(33): error C2144: syntax error: 'SAXParser' should be preceded by ';'include\mitsuba/render/scenehandler.h(33): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intinclude\mitsuba/render/scenehandler.h(37): error C2143: syntax error: missing ';' before 'namespace'include\mitsuba/render/scenehandler.h(37): error C4430: missing type specifier - int assumed. Note: C++ does not support default-intinclude\mitsuba/render/scenehandler.h(170): error C2039: 'XMLTranscoder': is not a member of 'xercesc_4_0'
  • 原因: xerces-c 4移除了一部分namespace相关宏定义, 需要手动将宏定义进行替换. 下面是需要替换的宏, 注意可能需要替换多个文件
   #define XERCES_CPP_NAMESPACE_BEGIN namespace XERCES_CPP_NAMESPACE {#define XERCES_CPP_NAMESPACE_END  }#define XERCES_CPP_NAMESPACE_USE using namespace XERCES_CPP_NAMESPACE;#define XERCES_CPP_NAMESPACE_QUALIFIER XERCES_CPP_NAMESPACE::
情况2: 字符串指针问题
src\librender\scenehandler.cpp(667): error C2664: 'void xercesc_4_0::SAXParser::setExternalNoNamespaceSchemaLocation(const XMLCh *const )': cannot convert argument 1 from 'const boost::filesystem::path::value_type *' to 'const XMLCh *const '
  • 原因: boost更新后, filesystem中的路径转字符串指针时, 需要首先转为string, 在转为字符串指针. 即将代码中 fs::path::c_str() 替换为 fs::path::string()::c_str(). 这里会涉及多个文件, 需要在编译的时候再检查替换

incomplete type ‘GLEWContextStruct’

  • include\mitsuba/core/tls.h(145): warning C4150: deletion of pointer to incomplete type 'GLEWContextStruct'; no destructor called
glrenderer.cpp
include\mitsuba/core/tls.h(145): warning C4150: deletion of pointer to incomplete type 'GLEWContextStruct'; no destructor called
include\mitsuba/hw/glrenderer.h(25): note: see declaration of 'GLEWContextStruct'
include\mitsuba/core/tls.h(143): note: while compiling class template member function 'void mitsuba::PrimitiveThreadLocal<GLEWContextStruct>::destruct(void *)'
include\mitsuba/core/tls.h(118): note: see reference to function template instantiation 'void mitsuba::PrimitiveThreadLocal<GLEWContextStruct>::destruct(void *)' being compiled
src\libhw\glrenderer.cpp(33): note: see reference to class template instantiation 'mitsuba::PrimitiveThreadLocal<GLEWContextStruct>' being compiled
include\mitsuba/core/tls.h(140): error C2027: use of undefined type 'GLEWContextStruct'
include\mitsuba/hw/glrenderer.h(25): note: see declaration of 'GLEWContextStruct'
include\mitsuba/core/tls.h(139): note: while compiling class template member function 'void *mitsuba::PrimitiveThreadLocal<GLEWContextStruct>::construct(void)'
include\mitsuba/core/tls.h(118): note: see reference to function template instantiation 'void *mitsuba::PrimitiveThreadLocal<GLEWContextStruct>::construct(void)' being compiled
scons: *** [build\release\libhw\glrenderer.obj] Error 2
scons: building terminated because of errors.
  • 原因: 新版本的glew没有GLEWContextStruct这一结构体了, 直接注释GLEWContextStruct相关的代码即可.

_1相关问题

   volcache.cppsrc\volume\volcache.cpp(180): error C2065: '_1': undeclared identifiersrc\volume\volcache.cpp(181): error C2065: '_1': undeclared identifiersrc\volume\volcache.cpp(179): error C2664: 'mitsuba::LRUCache<mitsuba::Vector3i,mitsuba::Vector3iKeyOrder,float *>::LRUCache(const mitsuba::LRUCache<mitsuba::Vector3i,mitsuba::Vector3iKeyOrder,float *> &)': cannot convert argument 1 from 'const size_t' to 'const mitsuba::LRUCache<mitsuba::Vector3i,mitsuba::Vector3iKeyOrder,float *> &'src\volume\volcache.cpp(181): note: Reason: cannot convert from 'const size_t' to 'const mitsuba::LRUCache<mitsuba::Vector3i,mitsuba::Vector3iKeyOrder,float *>'src\volume\volcache.cpp(181): note: No constructor could take the source type, or constructor overload resolution was ambiguousinclude\mitsuba/core/lrucache.h(153): note: see declaration of 'mitsuba::LRUCache<mitsuba::Vector3i,mitsuba::Vector3iKeyOrder,float *>::LRUCache'
  • _1修改为std::placehodlers::_1即可, 但需要修改多个地方

链接错误

OpenEXR

  • LINK: fatal error LNK1181: cannot open input file IlmImf.lib/lmThreadlib/Iex.lib
  • 原因: OpenEXR已经更名为libOpenEXR, 在config.py中将OEXRLIB修改为: OEXRLIB = ['OpenEXR-3_1', 'IlmThread-3_1', 'Iex-3_1', 'zlib']

GLEW

  • LINK : fatal error LNK1181: cannot open input file ‘glew32mx.lib’
  • config.py, GLLIB的第三个元素从glew32mx修改为glew32

后续/感想

  • 还是直接使用Mitsuba原来的依赖比较省心
  • SCons相比于CMake体验差的有点多, 后续打算更新一个cmake版本, 但该版本依旧在踩坑中(已完成)

CMake编译Mitsuba相关推荐

  1. Ubuntu 14.04上使用CMake编译MXNet源码操作步骤(C++)

    MXNet源码版本号为1.3.0,其它依赖库的版本号可参考:https://blog.csdn.net/fengbingchun/article/details/84997490 build.sh脚本 ...

  2. cmake编译出错:No CMAKE_CXX_COMPILER could be found.

    cmake编译出错:No CMAKE_CXX_COMPILER could be found. 错误类似: -- The CXX compiler identification is unknown- ...

  3. cmake编译安装完成后 执行cmake --version报错 bash: /usr/bin/cmake: 没有那个文件或目录

    cmake编译安装完成后 执行cmake --version报错 bash: /usr/bin/cmake: 没有那个文件或目录 cmake 没有那个目录 - 未完代码 - 博客园 因为直接使用cma ...

  4. [ c++] cmake 编译时 undefined reference to `std::cout‘ 错误的解决方案

    [ c++] cmake 编译时 undefined reference to `std::cout' 错误的解决方案 参考文章: (1)[ c++] cmake 编译时 undefined refe ...

  5. CMake编译Makefile

    以编译Libtif文件为例: 你可以用CMake编译libtiff,超简单,两个步骤. 参考文章 CharlesSimonyi,libtiff库的问题的答复 没有整理与归纳的知识,一文不值!高度概括与 ...

  6. cmake编译时支持gdb调试

    一般在调用./configure时,可以通过设置CXXFLAGS或者CFLAGS使程序可以支持调试,就是可以用GDB查看程序运行的信息,但在cmake编译时,在cmake过程和后面的make及make ...

  7. CMake编译Widget UI Qt程序

    自从CMake被引入到KDE项目的编译系统中后,CMake的使用者日益增多,Qt也不例外,除了使用QMAKE编译Qt程序外,也可以使用CMake来编译Qt程序,并且CMake在使用上更灵活,特别是大型 ...

  8. cmake重新编译matlab,ubuntu系统下cmake 编译matlab中mex文件

    cmake 编译工程具有独特的优势,特别对于复杂的工程更是如此.利用matlab直接编译mex文件时,对于文件数据多的工程时,需要列举所有文件,并且要按照依赖关系排 cmake 编译工程具有独特的优势 ...

  9. cmake 编译Release版本

    感谢作者: https://blog.csdn.net/sinat_31086489/article/details/84030871 # cmake 编译windows release 版本 在wi ...

最新文章

  1. C#使用WIN32API来高效率的遍历文件和目录(转)
  2. 把二叉搜索树转换为累加树
  3. REPAIR修复mysql报错is marked as crashed and should be
  4. 按键驱动的思路分析和代码实现
  5. 电子设计竞赛(4)-常用的两种PID算法
  6. 1.请求安全-- MD5的必要性以及实际应用场景
  7. vue 项目难点_Vue 项目里戳中你痛点的问题及解决办法
  8. Linux系统管理(6)——Linux下启动Redis服务的几种方法
  9. Docker 开发环境正在崩坏!
  10. 2x麦克劳林公式_极限求解-泰勒公式理解
  11. php抓取dom处理后数据,PHP简单DOMDocument抓取排除td类
  12. 一步一步理解日历calendar(一)
  13. PFQ: a Linux kernel module for packet capturing on multi-core architectures
  14. 关于人人开源的权限问题
  15. vue项目开发--网页小图标修改、封装导航栏
  16. 末学者笔记--Python函数三玄
  17. 【爬虫】【原创】08 使用简单正则表达式爬取下厨房(早餐,午餐,晚餐)
  18. 秒懂云通信:如何使用阿里云号码认证服务(小白指南)
  19. 第一章 接口测试基础
  20. 服务器显示ipv4有两个ip地址,ipconfig命令后为什么出现两个IPV4地址?

热门文章

  1. Win11如何删除升级包?Win11删除升级包的方法
  2. php 发型,大气宽屏发型网站模板
  3. 职称计算机模拟试题,职称计算机考试Windows模拟试题
  4. sequel pro格式化SQL
  5. linux程序 都用libc,uClinux的通用c库:uC-libc和uClibc的区别概述
  6. 可以PING通IP地址 但是PING不通网址(不能上网,能上QQ、下载)的解决(转载)
  7. 2W 行 | 深入理解「设计模式」
  8. 读《程序员的思维修炼》笔记
  9. 苹果系统自带的计算机怎么恢复出厂设置方法,Mac电脑初始化、恢复出厂设置方法...
  10. OpenJudge 7384(分成互质组)