OGRE 编译笔记

一时兴起,就编译一下 OGRE。编译流程没什么特别,就是 cmake 生成 Makefile 然后编译,选择 MinGW 作为编译器。


问题1:依赖第三方库文件


这次本来用的是 OgreDependencies_MinGW_20100216.zip 来解决依赖库的问题,但之后就出现问题了。MinGW 的版本与这些文件原来的版本不一致。


错误信息截选:


E:\devel\ogre\Dependencies\lib\release\libFreeImage.a(Plugin.o):Plugin.cpp:(.text+0xaf5): undefined reference to `__gxx_personality_sj0'
E:\devel\ogre\Dependencies\lib\release\libFreeImage.a(Plugin.o):Plugin.cpp:(.text+0xb17): undefined reference to `_Unwind_SjLj_Register'
E:\devel\ogre\Dependencies\lib\release\libFreeImage.a(Plugin.o):Plugin.cpp:(.text+0xbac): undefined reference to `_Unwind_SjLj_Unregister'
E:\devel\ogre\Dependencies\lib\release\libFreeImage.a(Plugin.o):Plugin.cpp:(.text+0xbd0): undefined reference to `_Unwind_SjLj_Resume'
E:\devel\ogre\Dependencies\lib\release\libFreeImage.a(Plugin.o):Plugin.cpp:(.text+0xc39): undefined reference to `__gxx_personality_sj0'
E:\devel\ogre\Dependencies\lib\release\libFreeImage.a(Plugin.o):Plugin.cpp:(.text+0xc5b): undefined reference to `_Unwind_SjLj_Register'
E:\devel\ogre\Dependencies\lib\release\libFreeImage.a(Plugin.o):Plugin.cpp:(.text+0xcf0): undefined reference to `_Unwind_SjLj_Unregister'
E:\devel\ogre\Dependencies\lib\release\libFreeImage.a(Plugin.o):Plugin.cpp:(.text+0xd14): undefined reference to `_Unwind_SjLj_Resume'
E:\devel\ogre\Dependencies\lib\release\libFreeImage.a(BitmapAccess.o):BitmapAccess.cpp:(.text+0xdd1): undefined reference to `__gxx_personality_sj0'

大致的意思 MinGW 用的异常处理库不一致,要么重新编译这些库,要么换个版本的 MinGW。


那就编译一下 FreeImage 吧。


1 下载: :http://cdnetworks-kr-1.dl.sourceforge.net/project/freeimage/Source%20Distribution/3.15.3/FreeImage3153.zip


2 解压编译: make -f Makefile.mingw


无奈又有错误了,错误信息:


Source/LibRawLite/./src/libraw_datastream.cpp: In constructor 'LibRaw_windows_datastream::LibRaw_windows_datastream(cons
t TCHAR*)':
Source/LibRawLite/./src/libraw_datastream.cpp:474:15: error: 'runtime_error' is not a member of 'std'
Source/LibRawLite/./src/libraw_datastream.cpp: In member function 'void LibRaw_windows_datastream::Open(void*)':
Source/LibRawLite/./src/libraw_datastream.cpp:506:30: error: 'runtime_error' is not a member of 'std'
Source/LibRawLite/./src/libraw_datastream.cpp:509:10: error: '::GetFileSizeEx' has not been declared
Source/LibRawLite/./src/libraw_datastream.cpp:510:15: error: 'runtime_error' is not a member of 'std'
Source/LibRawLite/./src/libraw_datastream.cpp:514:15: error: 'runtime_error' is not a member of 'std'
make: *** [Source/LibRawLite/./src/libraw_datastream.o] Error 1

好吧,加上

#include <stdexcept>

还有宏
#define WINVER 0x0500

需要静态库,设置一下


set FREEIMAGE_LIBRARY_TYPE=STATIC

这样就可以了,把编译好的 FreeImage.a 复制到 Dependencies 目录下,改名为 libFreeImage.a。


问题2:rc 文件编译问题


错误信息:


[ 37%] Building RC object OgreMain/CMakeFiles/OgreMain.dir/src/WIN32/OgreWin32Resources.rc.obj
D:\GS\MinGW\bin\windres.exe: invalid option -- m
Usage: D:\GS\MinGW\bin\windres.exe [option(s)] [input-file] [output-file]
 The options are:
  -i --input=<file>            Name input file
  -o --output=<file>           Name output file
  -J --input-format=<format>   Specify input format
  -O --output-format=<format>  Specify output format
  -F --target=<target>         Specify COFF target
     --preprocessor=<program>  Program to use to preprocess rc file
  -I --include-dir=<dir>       Include directory when preprocessing rc file
  -D --define <sym>[=<val>]    Define SYM when preprocessing rc file
  -U --undefine <sym>          Undefine SYM when preprocessing rc file
  -v --verbose                 Verbose - tells you what it's doing
  -c --codepage=<codepage>     Specify default codepage
  -l --language=<val>          Set language when reading rc file
     --use-temp-file           Use a temporary file instead of popen to read
                               the preprocessor output
     --no-use-temp-file        Use popen (default)
  -r                           Ignored for compatibility with rc
  @<file>                      Read options from <file>
  -h --help                    Print this help message
  -V --version                 Print version information
FORMAT is one of rc, res, or coff, and is deduced from the file name
extension if not specified.  A single file name is an input file.
No input-file is stdin, default rc.  No output-file is stdout, default rc.
D:\GS\MinGW\bin\windres.exe: supported targets: pe-i386 pei-i386 elf32-i386 elf32-little elf32-big srec symbolsrec veril
og tekhex binary ihex
make[2]: *** [OgreMain/CMakeFiles/OgreMain.dir/src/WIN32/OgreWin32Resources.rc.obj] Error 1
make[1]: *** [OgreMain/CMakeFiles/OgreMain.dir/all] Error 2
make: *** [all] Error 2

原因分析:大致是 windres 的参数有问题吧,暂时把参数去掉编译看看,后面有时间再仔细研究一下。


不得不感慨一下,编译过程实在煎熬,单进程编译消耗的时间太长,看来需要试试并行编译。


你可能感兴趣的:(OGRE 编译笔记)