歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Windows下編譯安裝PBRT V1.05

Windows下編譯安裝PBRT V1.05

日期:2017/2/28 15:42:30   编辑:Linux教程

由於要用到網上的一個插件。雖然現在PBRT已經出了V2版本。仍然需要編譯下PBRTV1版本。V1的各個版本功能相似,只是不斷的修正BUGS的過程。因此選擇了V1的最後一個版本PBRTV 1.05。

1)首先從官網上下載:

pbrt-src-1.05.zip, for Windows (620kB)

2)將文件解壓到目錄

c:\pbrt-v1

3)在Windows下編譯OpenEXR 見http://www.linuxidc.com/Linux/2012-08/68605.htm

4)先編譯項目core。通過後再編譯其他項目

在目錄C:\pbrt-v1\pbrt-1.05\win32下打開pbrt.sln

4.1)將配置屬性設置為All Configurations。

項目屬性->Configuration Properties->General->IntermediateDirectory設置為../tmp/$(ProjectName)/

Output Directory設置為../../bin

4.2) 在core項目的屬性裡VC++Directories中的Include Directories中加入:C:\Deploy\include

core項目右鍵->Properties->Linker->General->AdditionalLibrary Directories改為C:\Deploy\lib\Win32\Release

4.3)由於我用的是ZLIB-1.2.5版本,其對應的dll和lib分別為zlibwapi.dll和zlibwapi.lib

將core右鍵->Properties->Linker->AdditionalDependecies,將其改為:

Half.lib

Iex.lib

IlmImf.lib

Imath.lib

zlibwapi.lib

IlmThread.lib

4.4)在core目錄下新建文件unistd.h。內容如下:

#ifndef _UNISTD_H

#define _UNISTD_H

#include <io.h>

#include <process.h>

#endif /* _UNISTD_H */

4.5) 在core右鍵->Properties->C/C++->Preprocessor->PreprocessorDefinition部分加入OPENEXR_DLL

4.6) 在core/exrio.cpp文件中,注釋掉

#define hypotf hypot

4.7)編譯core項目成功

4.8) 將renderer右鍵->Properties->Build Events->Post-BuildEvent中的zlib1.dll換成zlibwapi.dll。並將zlibwapi.dll放在解決方案目錄下,即win32/目錄下。

4.9)修改所有項目的Output Directory為../../bin。

Intermediate Directory為../tmp/$(ProjectName)/

4.10)Build整個解決方案。

5)需要把C:\Deploy\bin\Win32\Release中的所有dll文件拷貝到C:\pbrt-v1\pbrt-1.05\bin中,並設定系統變量PBRT_SEARCHPATH指向C:\pbrt-v1\pbrt-1.05\bin

下載一個測試用的 pbrt 腳本文件,再寫個批處理腳本 pbrt.cmd,都放到PBRT 文件夾下的 \scenes 文件夾下,來測試下pbrt 程序吧,批處理腳本如下:

SET PATH=%PATH%;%PBRT_SEARCHPATH%

pbrt.exe sharp.pbrt

"..\...\bin\exrdisplay.exe" sharp.exr

遇到問題及解決方案:

1)c:\pbrt-v1\pbrt-1.05\core\exrio.cpp(29):fatal error C1083: Cannot open include file: 'ImfInputFile.h': No such file ordirectory

在core項目的屬性裡VC++Directories中的Include Directories中加入:C:\Deploy\include

2)c:\pbrt-v1\pbrt-1.05\core\pbrtlex.cpp(771):fatal error C1083: Cannot open include file: 'unistd.h': No such file ordirectory

在core目錄下新建文件unistd.h。內容如下:

#ifndef _UNISTD_H

#define _UNISTD_H

#include <io.h>

#include <process.h>

#endif /* _UNISTD_H */

3)c:\program files(x86)\microsoft visual studio 10.0\vc\include\math.h(167): error C2733: secondC linkage of overloaded function 'hypot' not allowed

解決方法,在exrio.cpp文件中,注釋掉

#define hypotf hypot

4)將core項目右鍵->Properties->Linker->General->AdditionalLibrary Directories改為C:\Deploy\lib\Win32\Release

5)由於我用的是ZLIB-1.2.5版本,其對應的dll和lib分別為zlibwapi.dll和zlibwapi.lib

將core右鍵->Properties->Linker->AdditionalDependecies,將其改為:

Half.lib

Iex.lib

IlmImf.lib

Imath.lib

zlibwapi.lib

IlmThread.lib

6)1>exrio.obj : errorLNK2001: unresolved external symbol "private: static union half::uif const* const half::_toFloat" (?_toFloat@half@@0QBTuif@1@B)

1>exrio.obj : error LNK2001: unresolved external symbol"private: static unsigned short const * const half::_eLut"(?_eLut@half@@0QBGB)

解決方案:在core右鍵->Properties->C/C++->Preprocessor->PreprocessorDefinition部分加入OPENEXR_DLL

7)C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(392,5):error MSB6003: The specified task executable "link.exe" could not berun. The process cannot access the file'C:\pbrt-v1\pbrt-1.05\win32\Projects\Debug\link.read.1.tlog' because it is beingused by another process.

原因:多個項目將tlog文件輸出到同一目錄,導致沖突。

解決方法:發現所有項目的IntermediateDirectory指定到不同的目錄。項目屬性->ConfigurationProperties->General->Intermediate Directory。原來為Debug\,將其改為../tmp/$(ProjectName)/

Copyright © Linux教程網 All Rights Reserved