【Ogre-windows】环境配置

前言

由于工程原因, 学习一下Ogre面向对象图形渲染开源引擎, 慢慢爬坑吧。首先还是环境的配置问题哎. 其实最重要的是要预先编译三方库, 虽然官方说可以自动编译, 但是在自己电脑上还是出现了无法解析外部符号之类的问题, 正常情况下我就认为是三方库的lib出现了问题, 最后额外编译三方库才得到了解决, 话不多说, 安装开始.

环境: windows10、VS2013、Ogre1.10

所需code:

官方网址: Ogre1.10(github)、三方库 、SDL2 、boost

【注】boost最好下载电脑所对应的VS版本, 我的电脑是VS2013, 所以下载boost_1_61_0-msvc-12.0-64.exe

百度网盘:

Ogre: 链接: https://pan.baidu.com/s/1TIPy-rndd-uBZJZynkvzrw 密码: uf5c

三方库: 链接:http://pan.baidu.com/s/1c1XCh0W 密码:db29

SDL2: 链接:http://pan.baidu.com/s/1qXAnaA4 密码:hegq

BOOST: 链接:http://pan.baidu.com/s/1pLMG7px 密码:q8a8

国际惯例, 参考博客:

OGRE 2.1 Windows 编译

官方manual

安装

三方库配置

  • 先安装boost, 一直下一步就行了, 我安装的位置是D:\Package\boost_1_61_0, 注意设置一下环境变量
    【Ogre-windows】环境配置_第1张图片
    再看看我安装后的目录有哪些文件

  • 新建一个文件夹Ogre1.10放置三方库以及后续的编译好的程序, 将三方库解压进来, 并在D:\Package\Ogre1.10\cabalistic-ogredeps-a337c4874a15\src新建文件夹SDL2, 将下载的SDL2压缩包中的大约40个文件复制丢进来, 并在D:\Package\Ogre1.10\cabalistic-ogredeps-a337c4874a15新建一个build文件夹, 接下来打开cmake-GUI, 设置好相关路径
    这里写图片描述

    直接点击Configure, 截图一下我的结果




    【Ogre-windows】环境配置_第2张图片
    调试日志如下:

    The C compiler identification is MSVC 18.0.40629.0
    The CXX compiler identification is MSVC 18.0.40629.0
    Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
    Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
    Detecting C compiler ABI info
    Detecting C compiler ABI info - done
    Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe
    Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/cl.exe -- works
    Detecting CXX compiler ABI info
    Detecting CXX compiler ABI info - done
    Detecting CXX compile features
    Detecting CXX compile features - done
    Looking for DirectX...
    DirectX_PREFIX_PATH changed.
    Check size of void*
    Check size of void* - done
    Found DirectX: C:/Program Files (x86)/Windows Kits/8.1/Lib/winv6.3/um/x86/d3d9.lib
    DX lib dir: C:/Program Files (x86)/Windows Kits/8.1/Lib/winv6.3/um/x86
    DX lib dir: C:/Program Files (x86)/Windows Kits/8.1/Lib/winv6.3/um/x86
    Check size of void*
    Check size of void* - done
    Configuring done

    虽然全是红色的, 但是再Configure一下就没了, 如果还有红色的, 那你就得好好核对一下我上面贴的一堆图了. 随后Generate一下, 就看到build文件夹下已经有完整的VS工程啦
    【Ogre-windows】环境配置_第3张图片

    然后打开OGREDEPS.sln, 对ALL_BUILD生成一次, 就发生问题了

    错误    944 error MSB6006: “cmd.exe”已退出,代码为 1。  C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets  170 5   SDL2

    这时候就考察VS的调试功底了, 直接去输出窗口看具体位置:

    5>  Move SDL2 install files into the Release and Debug folders.
    5>  CMake Error at D:/Package/Ogre1.10/cabalistic-ogredeps-a337c4874a15/build/src/SDL2-prefix/src/SDL2-stamp/SDL2-MoveInstallFiles-Debug.cmake:16 (message):
    5>    Command failed: 1
    5>  
    5>     'C:/Program Files/CMake/bin/cmake.exe' '-Dmake=' '-Dconfig=Debug' '-P' 'D:/Package/Ogre1.10/cabalistic-ogredeps-a337c4874a15/build/src/SDL2-prefix/src/SDL2-stamp/SDL2-MoveInstallFiles-Debug-impl.cmake'
    5>  
    5>    See also
    5>  
    5>      D:/Package/Ogre1.10/cabalistic-ogredeps-a337c4874a15/build/src/SDL2-prefix/src/SDL2-stamp/SDL2-MoveInstallFiles-*.log
    5>  
    5>  
    5>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(170,5): error MSB6006: “cmd.exe”已退出,代码为 1

    很清晰地发现错误日志已经被丢到SDL2-MoveInstallFiles-*.log中, 去瞅一眼

    Error copying file "bin/SDL2.dll" to "bin/Debug/SDL2.dll".
    CMake Error at D:/Package/Ogre1.10/cabalistic-ogredeps-a337c4874a15/build/src/SDL2-prefix/src/SDL2-stamp/SDL2-MoveInstallFiles-Debug-impl.cmake:29 (message):
    Command failed (1):
     'C:/Program Files/CMake/bin/cmake.exe' '-E' 'copy' 'bin/SDL2.dll' 'bin/Debug/SDL2.dll'

    很多人看到这类英文错误就直接问人, 小兄弟啊, 遇到错误先认真看一遍, 至少先翻译一下也行啊. 嗯, 闲话不多说, 这个问题就是复制SDL2.dll的时候出问题了, 三方库的输出目录是D:\Package\Ogre1.10\cabalistic-ogredeps-a337c4874a15\build\ogredeps, 可以发现在bin下的确有SDL2d.dll躺着, 主要是由于我们编译的是Debug模式. 所以没找到SDL2.dll, 导致错误, 解决方法很简单, 切换Release模式重新编译, 或者手动把这个文件拷贝进去.建议两个都做一遍, 反正不冲突.

  • 最后对INSTALL生成一遍,一定要核对一下相关文件(VS工程中出现的那几个三方库)是否在ogredeps文件中, 主要有
    include: 相关头文件, 这个一般都存在
    lib: 相关lib库文件
    bin: 相关dll库文件
    如果不在, 直接针对每个项目右键打开文件资源管理器, 找到以后复制过来.

编译Ogre源程序

  • ogre-master解压到D:\Package\Ogre1.10中, 然后将刚才编译的三方库ogredeps放入到ogre-master中, 并更名为Dependencies, 在D:\Package\Ogre1.10下新建文件夹Ogre用于存储编译的Ogre, 在cmake-gui中设置路径
    这里写图片描述
    然后Configure, 调试信息太多了, 就不贴了, 第二次Configure出现错误

    send_errorD:/Package/Ogre1.10/Ogre/Dependencies/bin/debug/cg.dll did not exist, can't install!
    send_errorD:/Package/Ogre1.10/Ogre/Dependencies/bin/release/cg.dll did not exist, can't install!

    这个文件在刚才编译三方库的时候D:\Package\Ogre1.10\cabalistic-ogredeps-a337c4874a15\build\bin里面, 同时我们还发现另外两个dll: OIS.dllRemotery.dll, 保险起见都复制过去吧,两种模式DebugRelease, 重新Configure就没问题了, 调试日志如下

Configuring OGRE 1.10.10
  Search path: D:/Package/Ogre1.10/Ogre/Dependencies;D:/Package/Ogre1.10/ogre-master/Dependencies;D:/Package/Ogre1.10/Ogre/../Dependencies;D:/Package/Ogre1.10/ogre-master/../Dependencies
  Looking for ZZip...
  Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
  Found ZZip: optimized;D:/Package/Ogre1.10/ogre-master/Dependencies/lib/Release/zziplib.lib;debug;D:/Package/Ogre1.10/ogre-master/Dependencies/lib/Debug/zziplib_d.lib
  Looking for FreeImage...
  Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
  Found FreeImage: optimized;D:/Package/Ogre1.10/ogre-master/Dependencies/lib/Release/FreeImage.lib;debug;D:/Package/Ogre1.10/ogre-master/Dependencies/lib/Debug/FreeImage_d.lib
  Looking for FREETYPE...
  Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
  CMAKE_PREFIX_PATH: D:/Package/Ogre1.10/Ogre/Dependencies;D:/Package/Ogre1.10/ogre-master/Dependencies;D:/Package/Ogre1.10/Ogre/../Dependencies;D:/Package/Ogre1.10/ogre-master/../Dependencies
  CMAKE_PREFIX_PATH: D:/Package/Ogre1.10/Ogre/Dependencies;D:/Package/Ogre1.10/ogre-master/Dependencies;D:/Package/Ogre1.10/Ogre/../Dependencies;D:/Package/Ogre1.10/ogre-master/../Dependencies
  Found FREETYPE: optimized;D:/Package/Ogre1.10/Ogre/Dependencies/lib/freetype.lib;debug;D:/Package/Ogre1.10/ogre-master/Dependencies/lib/Debug/freetype_d.lib
  Looking for DirectX9...
  Found DirectX9: D:/Package/Microsoft DirectX SDK (June 2010)/Lib/x86/d3d9.lib
  Looking for DirectX11...
  Found DirectX11: d3d11.lib;dxgi.lib;dxguid.lib
  Looking for Cg...
  Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
  Found Cg: D:/Package/Ogre1.10/ogre-master/Dependencies/lib/Release/cg.lib
  Looking for POCO...
  Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
  Could not locate POCO
  Looking for TBB...
  Could not locate TBB
  Looking for GLSL_Optimizer...
  Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
  Could not locate GLSL_Optimizer
  Looking for HLSL2GLSL...
  Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
  Could not locate HLSL2GLSL
  Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
  Looking for Softimage...
  Could not locate Softimage

  -----------------------------------------------------------------------------
  -- The following external packages were located on your system.
  -- This installation will have the extra features provided by these packages.
  + zlib
  + zziplib
  + freeimage
  + freetype
  + OpenGL
  + OpenGL 3+
  + OpenGL ES 1.x
  + OpenGL ES 2.x
  + OpenGL ES 3.x
  + DirectX9
  + DirectX11
  + cg
  + Python
  + SDL2
  -----------------------------------------------------------------------------
  -- The following OPTIONAL packages could NOT be located on your system.
  -- Consider installing them to enable more features from this software.
  + boost: Boost (general) 
  + boost-thread: Used for threading support 
  + POCO: POCO framework 
  + tbb: Threading Building Blocks 
  + GLSL Optimizer: GLSL Optimizer 
  + HLSL2GLSL: HLSL2GLSL 
  + OpenEXR: Load High dynamic range images 
  + Doxygen: Tool for building API documentation 
  + Softimage: Softimage SDK needed for building XSIExporter 
  -----------------------------------------------------------------------------

  Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR) 
  Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR) 

  ----------------------------------------------------------------------------
    FEATURE SUMMARY
  ----------------------------------------------------------------------------

  Building components:
    + Bites [BETA]
    + HLMS [BETA]
    + MeshLodGenerator
    + Overlay
    + Paging
    + Property [DEPRECATED]
    + Python [BETA]
    + Java/ JNI [BETA]
    + RTShader System
    + RTShader System Core Shaders
    + RTShader System Extensions Shaders
    + Terrain
    + Volume
  Building plugins:
    + BSP scene manager
    + Cg program manager
    + Octree scene manager
    + Portal connected zone scene manager
    + Particle FX
  Building rendersystems:
    + Direct3D 9
    + Direct3D 11
    + OpenGL
    + OpenGL 3+
  Building executables:
    + Samples
    + Tools
  Building core features:
    + Mesh Lod
    + DDS image codec (.dds)
    + ETC image codec (.pkm, .ktx) 
    + FreeImage codec (generic)
    + ZIP archives

  Build type:                      shared
  Use C++11 std library:           OFF
  Store child nodes as:            map [DEPRECATED]
  Thread safety:                   none
  ResourceManager behaviour:       legacy [DEPRECATED]
  Use double precision:            disabled
  Nodes inherit transform:         disabled
  Assert mode:                     release exceptions
  Allocator type:                  standard
  STL containers use allocator:    disabled
  Strings use allocator:           disabled
  Memory tracker (debug):          disabled
  Memory tracker (release):        disabled

  ----------------------------------------------------------------------------

  Configuring done
  Generating done

Generate一下, 生成VS2013的工程文件, 可以在D:\Package\Ogre1.10\Ogre中找到.
【注】上述过程也可以在Cmake-GUI中不勾选OGRE_BUILD_DEPENDENCIES,并且设置OGRE_DEPENDENCIES_DIR为你的三方库目录, 好像更快一些
- 编译OGRE.sln, 先ALL_BUILD一下, 时间挺久的, 要盯着错误列表, 一旦出现错误, 就直接取消生成解决错误吧. 个人觉得很多人会出现外部符号无法解析问题, 一定是由于lib文件没折腾好引起的. 重新仔细核对上述步骤, 尤其是核对dll和lib是否折腾对.
【注】这里贴一下我编译好的三方库,便于大家核对 :链接:http://pan.baidu.com/s/1boDvokv 密码:lkap
然后就可以INSTALL啦, 这个就是生成我们后续开发需要引用的Ogre各种文件, 存在于D:\Package\Ogre1.10\Ogre\sdk目录下, 以后开发就只需要它应该就可以了.

  • 最后可以通过VS运行程序, 也可以通过D:\Package\Ogre1.10\Ogre\bin\debug\SampleBrowser_d.exe运行程序

你可能感兴趣的:(运动捕捉)