以下为实践过程;
一 , Download OgreSourceCode
http://www.ogre3d.org/download/source
二,研究BuildingOgre.txt
解压下载的Ogre 源码之后,可以在根目录下找到BuildingOgre.txt,按照BuildingOgre.txts
所介绍的开始进行compile;
三, Getting CMake
Downfrom http://www.cmake.org, 安装cmake, 安装成功之后,可以运行cmake-gui来进行编译工作;
打开cmake-gui, 指定
Where is the source code ---- Ogre Source code 所在目录;假设为D:\Sourcecode\ogre\ogre_src
Where to build the binaries ---- 可以新建一个目录,来指定此目录,假设为
D:\Sourcecode\ogre\buildOrge
四, Gettingdependencies
下载编译Ogre需要的一些lib and dll,这里需要重点讲一下;
1,Dependencies
http://www.ogre3d.org/download/source中提供了一个DependenciesSource Repository with CMake build system 这样的一个压缩包,解压之后名为Dependencies,在其中包含了Cg, FreeImage, freeType, ois,zlib, zziplib; 将Dependencies 放在D:\Sourcecode\ogre\buildOrge
目录下,使用VS2005 编译Dependencies 所包含的所有lib;
下面来处理Dependencies中不包含的那些库文件;
2,DirectX
安装Microsoft DirectX SDK
3,POCO
解压之后,运行build_vs80.cmd, 即使用VS2005编译poco
同时,在cmake-gui中,点击Add Entry, 新建一个path, 可以命名为POCO_HOME, 指向poco所在的文件夹,这样在编译的时候,可以找到poco;
4,CPPUNIT
http://sourceforge.net/projects/cppunit/files/cppunit/
加压之后,进入src, 使用VS2005 打开CppUnitLibraries.dsw, 编译整个工程;
编完之后,在cmake-gui中,点击Add Entry, 新建一个path, 可以命名为CPPUNIT_HOME, 指向cppunit所在的文件夹,这样在编译的时候,可以找到cppunit;
5, Doxygen
http://www.stack.nl/~dimitri/doxygen/download.html
download 适合windows的安装文件,进行安装;
6,Boost
download适合windows的zip or 7z;
直接运行bootstrap.bat, 会由于Path的缘故而fail, 所以直接打开 开始-程序-Microsoft Visual Studio 2005-Visual Studio Tools – Visual Stual2005 命令提示, 这个VS2005就为我们设定好了相应的path,执行ootstrap.bat;
运行bootstrap.bat成功,将得到bjam.exe, 直接双击运行bjam.exe会出现很多error, 找不到相关文件之类的,可以通过增加path来解决,同样为了方便,进入Visual Stual2005 命令提示,转到bjam.exe 所在目录,
运行
bjam --toolset=msvc-8.0 --build-type=complete --layout=versioned
(bjam --toolset=msvc-8.0 --without-python --build-type=complete link=shared threading=multi install)
toolset 选项指定编译器,VS2005指定为msvc-8.0
build-type 选项指定编译类型
PS: 环境变量Path被破坏后,会使VC\bin\vcvars32.bat,加载path fail, 引起编译错误;
CMakedepends on the following environment variables to find Boost succesfully:
BOOST_ROOT (d:\ boost)
BOOST_INCLUDEDIR (d:\ boost)
BOOST_LIBRARYDIR (d:\ boost\libs)
Well, at least BOOST_ROOT, but it can't hurt to set the twoothers.
如此编译完成之后,在cmake-gui中,点击Add Entry, 新建多个path, 分别为BOOST_ROOT,
BOOST_INCLUDEDIR, BOOST_LIBRARYDIR
7, GLSL
Optimizer: GLSL Optimizer http://github.com/aras-p/glsl-optimizer/
使用cmake-gui 产生Project.sln, 使用VS2005打开,进行编译,发现找不到stdint.hstdboo.h,
在根目录include下会有c99这个文件夹,将c99添加到包含目录;
发现找不到getopt.h, 将src\getopt 添加到包含目录;
使用VS2005编译过程中,可能会遇到一些问题,主要涉及VS2005对c99支持的不是
很好、 wgl相关——VS2005默认缺少一些opengl 开发库, 需要进行添加,注意修改就OK;
8, HLSL
HLSL2GLSLhttp://hlsl2glslfork.googlecode.com/
9, tbb
ThreadingBuilding Blocks http://www.threadingbuildingblocks.org/
10, SoftImage
Softimage SDKneeded for building XSIExporter <FALSE>
五:cmake-gui Configureand Generate
六:BuildingOgre
在D:\Sourcecode\ogre\buildOrge 下找到OGRE.sln, 用VS2005打开,进行编译;
If you havedoxygen installed and CMake picked it up,then there will be an additional build target called doc whichyou can optionally build. 使用VS2005 select and build the target 'DOC' ;
七:InstallingOgre
In Visual Studio, just select and build thetarget 'INSTALL'. This will create the folder 'sdk' inside your build directoryand copy all the required libraries there.
更多详细编译可参考官方文档http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Building+Ogre