- 这篇文章主要记录了更新Mitsuba依赖, 以及在VS2019, Python3.9等等比较现代的环境下编译的过程.
- 为了编译Mitsuba, 我写了一个CMakeLists专门用来下载和编译依赖; 源码也为了适应新的依赖做了一点修改. 修改后的版本已经放在了Github上, 按照 Readme 应当是能够直接编译的. (有问题欢迎issue, 我会尽量回复)
Mitsuba
- Mitsuba是面向科研的离线渲染框架, 虽然现在已经有了Mitsuba2, 但 Mitsuba 0.6.0 还是因为功能齐全/简单好用, 经常在各种Siggraph论文里被用于实现算法.
- 用Mitsuba最麻烦的一点是年久失修, 这里指的是编译的工具链过时. Mitsuba的代码质量非常优秀, 只是因为太久没有更新维护导致各种依赖跟不上现在的版本.
- 编译思路主要是自行编译依赖. 如果手动下载, 配置和编译依赖肯定会很麻烦. 但是幸好我们有CMake, 只要几行代码就可以自动编译一个库, 编译完还能将依赖拷贝到对应的地方.
环境/准备工作
- 这里所指的环境是必须手动去官网准备的, 因为这些软件安装比较麻烦, 个人没办法简单地用脚本完成环境配置, 所以需要手动下载和安装
- 注意这里的环境只要大版本相同即可, 小版本是我的个人选择
依赖
这是整个编译过程中最麻烦, 花费时间最多的部分. Mitsuba官方提供了编译好的依赖, 但就是因为他们是编译好的, 有些依赖在VS2019下链接不上. 所以需要自行把Mitsuba的依赖进行更新.
- 注意: 这一部分的所有命令行操作请在 64 位的 VS Command Prompt 下执行, 否则
cl.exe , lib.exe 等等可能会找不到命令
通过CMake下载和编译依赖
我写了一个CMake的脚本, 将Mitsuba用到的依赖都更新到了当前最新(?)的版本, 脚本可在Github上自取. 依赖编译的时间会比较长, 需要耐心等待.
在使用之前, 需要做部分说明
- 再次强调, 所有命令行操作请在 64 位的 VS Command Prompt 下执行
- 请确保网络状况良好, 能够下载和克隆外网/github上的内容. 代理请开启全局代理
CMakeLists.txt 中有部分内容需要自行修改:
- Line7:
set(COMPILE_THREAD 20) 这里设置的是编译依赖时并行的线程数, 20表示使用20个线程, 设置为本机CPU核数即可. - Line8 & Line9: 这里设置的是下载时的代理, 如果你不需要, 或者你不知道这是什么意思, 请将这两行注释掉.
- 如果你的网络状况不好, 没有办法通过CMake下载, 或者下载下来的东西是损坏的/是0KB的, 那请参考后面"依赖列表"部分, 手动下载/克隆依赖, 然后放到
dependencies/Downloads 中. 完成下载后再接着下面的步骤运行
具体使用的步骤是这样的:
- 在Mitsuba项目下新建
dependencies 文件夹, 然后将CMakeLists.txt 复制进去 - 命令行进入
dependencies 目录 - 运行
cmake ./
经过漫长的编译后, 依赖就配置完成了. 如果你不确定有没有完成, 那没有关系, 也可以直接跳到"Mitsuba编译"部分. 发生依赖错误的时候在回来, 然后将CMakeLists.txt 中其他的依赖配置代码注释掉, 只留下没有配置成功的依赖, 然后再次运行cmake ./ .
依赖列表
- 下面是
CMakeLists.txt 中包含的依赖列表, 如果你的网络是在太差, 或者不知道怎么让CMake通过代理下载/克隆依赖, 可以参考下面的列表, 手动将需要下载的内容下载好. - 这里面所有需要下载/克隆的内容, 无论是压缩包还是文件, 还是文件夹, 都放在
dependencies/Downloads 下即可 - 下面的列表"路径/文件名"一列中, 带"/"表示这是文件夹, 否则是文件
依赖 | 路径/文件名 | 克隆命令/下载地址 |
---|
version | version | https://github.com/mitsuba-renderer/dependencies_win64/raw/master/version | 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 等可执行文件
配置和编译
修改配置文件
- Mitsuba依靠SCons进行编译, 由于Mitsuba原始的SCons是基于Python2的, 而且Mitsuba的依赖也是我们自己编译的最新版本, 所以需要修改配置文件.
- 这里的部分配置会涉及到依赖的版本, 如果你的环境/依赖与我不同, 请自行做微调(例如v142调成v141, Qt的安装目录做些修改之类的). 最关键的就是, 要把你的依赖名称/目录写正确, 让编译器能够找到这个依赖.
config.py
- SCons需要读取项目根目录下的
config.py 作为配置, Mitsuba官方在build/ 下提供了几个模板, 我们基于这些模板来做修改: 复制build/config-win64-msvc2017.py 到config.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'] 我们用的是版本4GLLIB : 将其中的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
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"]
- 建议将检查Qt5的异常捕获关闭, 因为我们需要编译Gui
env = Environment(options=vars, ENV = os.environ, tools=['default', 'qt5'], toolpath=['#data/scons'])
print('Checking for Qt 5.x... yes')
hasQt = True
- 194行的OpenEXR检查需要更新路径, 不知道为什么使用"ImfRgba.h"始终返回False, 这里用
'openexr.h' 代替
if not conf.CheckCXXHeader('openexr.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 会抛出异常, 所以需要这样修改:
class ToolQtWarning():
pass
class GeneratedMocFileNotIncluded(ToolQtWarning):
pass
class QtdirNotFound(ToolQtWarning):
pass
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'
archType = 'x64' if 'WIN64' in env['CXXFLAGS'] else 'i386'
dllprefix = '#dependencies/bin'
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)
for boostlib in ['python39', '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)
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'])
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() {
void seekg(uint64_t pos) {
uint64_t tellp() {
void seekp(uint64_t pos) {
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.h 将vsnprintf 进行了宏替换, 新版本的boost/MSVC已经不需要这样做了, 这里将用宏定义#if (defined(_MSC_VER) && _MSC_VER < 1900) 把替换的内容注释掉.
#if (defined(_MSC_VER) && _MSC_VER < 1900)
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#endif
SAXParser 相关语法错误
情况1: 命名空间相关错误
util.cpp
include\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-int
include\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-int
include\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.cpp
src\volume\volcache.cpp(180): error C2065: '_1': undeclared identifier
src\volume\volcache.cpp(181): error C2065: '_1': undeclared identifier
src\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 ambiguous
include\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版本, 但该版本依旧在踩坑中~
|