牵着老婆满街逛

严以律己,宽以待人. 三思而后行.
GMail/GTalk: yanglinbo#google.com;
MSN/Email: tx7do#yahoo.com.cn;
QQ: 3 0 3 3 9 6 9 2 0 .

CELayoutEditor编译详尽步骤

转自:http://www.cegui.org.uk/phpBB2/viewtopic.php?t=2760

Hi all,

------------------------------------------------------------------------------------------------------
    CELAYOUTEDITOR BUILD STEPS FOR VS2003-5 (V1.5c)
------------------------------------------------------------------------------------------------------


This small document details the steps needed to successfully build the latest TRUNK/HEAD version of CELayoutEditor against WXWidgets V2.8.* (source) and CEGUI latest SVN version, using VS2003 (7.1) or VS2005 (8.0) with SP1 in Windows XP SP2 and TortoiseSVN as the SVN client.

NOTE: For similar steps, but for the CEImagesetEditor, check http://www.cegui.org.uk/phpBB2/viewtopic.php?t=2780.
TODO: Add to wiki!

This guide was built and tested in both VS2003 (7.1) and VS2005 (8.0) only! However, it is more than likely that most steps (if not all) will be valid for other versions of Visual Studio (7.0, 6.0).
NOTE (06/11/07): Please note that Visual studio 6 is no longer officially supported!

This is my particular way of doing things and reflects my own experience with CELayoutEditor builds. Therefore, it might not be the most correct approach. I hope it might be helpful still, especially to newcomers.

IMPORTANT NOTE (22/10/07): Due to recent SVN trunk changes to CELayoutEditor, the CEGUI binaries and zipped source found in the CEGUI download area can no longer be used to compile CELayoutEditor. The reason is that the editor requires changes that are only available (at this time) in the CEGUI SVN trunk.

History:
    NOTE: Dates use the dd/mm/yy format.
    - Version 1.5c - 10/12/07 - Added requirements section.
    - Version 1.5b - 07/12/07 - Updated guide to wxWidgets 2.8.7.
    - Version 1.5 - 06/11/07 - Guide now contemplates VS2003 as well. Added mention that Visual Studio 6 is no longer officially supported. Updated guide to wxWidgets 2.8.6. Added wxUSE_ABOUTDLG. Added splash screen. Some style modifications.
    - Version 1.4 - 22/10/07 - Added note about different VS versions and a few others explaining that you'll need to use CEGUI SVN (and not the binaries or zipped source) to build the CELayoutEditor SVN version due to recent changes (thanks go to daviticus).
    - Version 1.3c - 19/10/07 - Added recommendation about wxUSE_EXCEPTIONS.
    - Version 1.3b - 11/10/07 - Added note that VC++8 solution is already in SVN. Fixed incorrect setup.h paths. Added reference to CEImagesetEditor equivalent steps. Fixed incorrect URLs.
    - Version 1.3 - 09/10/07 - Corrected the SILLY DLL problem (thanks to dmail).
    - Version 1.2 - 26/09/07 - Added option to build CEGUI from SVN.
    - Version 1.1 - 15/09/07 - Added option to build CEGUI from source.
    - Version 1.0 - 13/09/07 - Initial release.
IMPORTANT NOTE: Be wary of concurrent installs of VS 7 and VS 8. If you are using VS 8, be sure to build all necessary solutions (CEGUI, WxWidgets and CELayoutEditor) using VS 8 and NEVER VS7. Otherwise, you'll get quite a lot of linker errors! The opposite also holds true.

0) REQUIREMENTS:
-----------------------

CELayoutEditor requires the use of some third party external libraries. These libraries are as follows:

This guide will offer detailed instructions on how to build them.

1) INIT:
----------

1. Close all instances of Visual Studio

2) CEGUI DOWNLOAD & SETUP:
---------------------------------------

NOTE: As mentioned above, the latest CEGUI binaries or the zipped source (0.5.0b at the time of this writing) can no longer be used to build the latest CELayoutEditor SVN. They are still presented below for reference purposes.

We now need to get the latest CEGUI SVN trunk version.

Build CEGUI binaries (reference only)
-------------------------------------------

NOTE: Use 'Build CEGUI SVN' below to correctly build the CELayoutEditor SVN version.

2.1 Download CEGUI 0.5.0b binaries for VC++ 8 or VC++ 7.1 from http://www.cegui.org.uk/wiki/index.php/CEGUI_Downloads_0.5.0.

2.2 Install CEGUI in desired directory.

2.3 Create an environment variable $(CEGUI) that will store the previous dir.
    2.3.1 Go to My Computer\Properties\Advanced\Environment Variables.

    2.3.2 Press new in the user variables area.

    2.3.3 Create a new variable named CEGUI and with the directory present in 2.2 as value (e.g. D:\Dev\CEGUI-SDK-0.5.0b-vc8).

Build CEGUI source (reference only)
------------------------------------------

NOTE: Use 'Build CEGUI SVN' below to correctly build the CELayoutEditor SVN version.

2.1 Download CEGUI 0.5.0b source from http://www.cegui.org.uk/wiki/index.php/CEGUI_Downloads_0.5.0.

2.2 Unpack previous zip to directory of your choice.

2.3 Create an environment variable $(CEGUI) that will store the previous dir.
    2.3.1 Go to My Computer\Properties\Advanced\Environment Variables.

    2.3.2 Press new in the user variables area.

    2.3.3 Create a new variable named CEGUI and with the directory present in 2.2 as value (e.g. D:\Dev\CEGUI-0.5.0).
2.4 Download CEGUI 0.5.0b dependencies for VC++8 or VC++ 7.1 from http://www.cegui.org.uk/wiki/index.php/CEGUI_Downloads_0.5.0.

2.5 Unpack dependencies to $(CEGUI) directory.

2.6 Go to $(CEGUI)\makefiles\premake and run build_vs2005.bat or build_vs2003.bat (these batch files use premake to generate the VS2005 and VS2003 solution respectively).

2.7 Open the generated $(CEGUI)\makefiles\premake\CEGUI.sln.

2.8 Build the solution in both DEBUG and RELEASE configurations.

Build CEGUI source (SVN)
-----------------------------

NOTE: I'm using TortoiseSVN as my SVN client for illustration purposes, but you can use anything you like.

2.1 In Windows Explorer, pick a directory of your choice and create a directory named CEGUI-0.5.0-SVN or any other name of your choice.

2.2 Right click in the previous directory and choose the TortoiseSVN right-mouse menu option 'SVN Checkout...'.

2.3 We want the HEAD version here, so use https://crayzedsgui.svn.sourceforge.net/svnroot/crayzedsgui/cegui_mk2/trunk as the 'URL of repository'.

2.4 Choose 'Head revision' radio button and press OK.

2.5 Create an environment variable $(CEGUI) that will store the previous dir.
    2.5.1 Go to My Computer\Properties\Advanced\Environment Variables.

    2.5.2 Press new in the user variables area.

    2.5.3 Create a new variable named CEGUI and with the directory present in 2.1 as value (e.g. D:\Dev\CEGUI-0.5.0-SVN).
2.6 Download CEGUI 0.5.0b dependencies for VC++8 or VC++7.1 from http://www.cegui.org.uk/wiki/index.php/CEGUI_Downloads_0.5.0.

2.7 Unpack dependencies to $(CEGUI) directory.

NOTE: Premake is not available in the SVN repository, so you'll need to download and install it

2.8 Go to http://premake.sourceforge.net/download.

2.9 Download the latest premake version for windows (at the time of this writing, premake-win32-3.4.zip).

2.10 Unpack premake.exe to $(CEGUI)\makefiles\premake or any directory in the system path.

2.11 Go to $(CEGUI)\makefiles\premake and run build_vs2005.bat or build_vs2003.bat (these batch files use premake to generate the VS2005 and VS2003 solution respectively).

2.12 Open the generated $(CEGUI)\makefiles\premake\CEGUI.sln.

2.13 Build the solution in both DEBUG and RELEASE configurations.


3) WXWIDGETS DOWNLOAD & SETUP:
----------------------------------------------

Time to retrieve the latest WxWidgets source version (2.8.7 at the time of this writing). This is a required dependency of CELayoutEditor and will need to be built later on.

NOTE: CELayoutEditor requires wxWidgets 2.8.* or higher. This guide has been tested with the following versions: 2.8.7, 2.8.6, 2.8.5.

3.1 Go to http://www.wxwidgets.org/downloads/ and dowload wxAll source archive for version 2.8.7.

3.2 Unpack the previous tar (wxWidgets-2.8.7.tar.tar) to a directory of your choice.

3.3 Create an environment variable $(WXWIDGETS) that will store the previous dir.

    3.3.1 Go to My Computer\Properties\Advanced\Environment Variables.

    3.3.2 Press new in the user variables area.

    3.3.3 Create a new variable named WXWIDGETS and with the directory present in 3.2 as value (e.g. D:\Dev\wxWidgets-2.8.7).

4) CELAYOUTEDITOR RETRIEVAL & SETUP:
---------------------------------------------------

Instead of downloading a source or binary version, we'll retrieve the latest CELayoutEditor version directly from the TRUNK/HEAD of SVN. I did this because I wanted to work with the latest patches, but you might choose to use a more stable version if you prefer.

NOTE: I'm using TortoiseSVN as my SVN client for illustration purposes, but you can use anything you like.

4.1 In Windows Explorer, pick a directory of your choice and create a directory named CELayoutEditor.

4.2 Right click in the previous directory and choose the TortoiseSVN right-mouse menu option SVN Checkout...'.

4.3 We want the HEAD version here, so use https://crayzedsgui.svn.sourceforge.net/svnroot/crayzedsgui/CELayoutEditor/trunk as the 'URL of repository'.

4.4 Choose 'Head revision' radio button and press OK.

4.5 Create an environment variable $(CE_LAYOUT_EDITOR) that will store the previous dir.

    4.5.1 Go to My Computer\Properties\Advanced\Environment Variables.

    4.5.2 Press new in the user variables area.

    4.5.3 Create a new variable named CE_LAYOUT_EDITOR and with the directory present in 4.1 as value (e.g. D:\Dev\CELayoutEditor).

5) CELAYOUTEDITOR SOLUTION CONFIG:
-------------------------------------------------

IMPORTANT NOTE: As of 10/10/07, the VC++8 (VS2005) solution is already present in SVN, configured with the correct environment variables mentioned in this section. On 05/11/07, the VC++7.1 (VS2003) suffered the same fate. You can now skip to section 6 directly. This section is kept for reference purposes.

Let's prepare the build process. You'll notice that no CELayoutEditor solution exists for VC++8 (only for 6 and 7). So, if using VS2005, go to 5.1. Otherwise, open $(CE_LAYOUT_EDITOR)\vc++7.1\CELayoutEditor.sln and go to 5.5:

5.1 Create a new directory named vc++8 in $(CE_LAYOUT_EDITOR)

5.2 Copy the contents of $(CE_LAYOUT_EDITOR)\vc++7.1 to $(CE_LAYOUT_EDITOR)\vc++8

5.3 Open $(CE_LAYOUT_EDITOR)\vc++8\CELayoutEditor.sln in VS2005.

5.4 When prompted, convert project to VC++8.

5.5 Right click the CELayoutEditor project in the Solution Explorer and choose properties.

5.6 Navigate to ConfigurationProperties\C/C++\General

5.7 Open the Additional Include Directories panel

5.8 Remove the following two lines - that refer to SVN relative paths where CEGUI is located and therefore not needed since our own paths will probably differ - in both Debug and Release configurations (top-left dropdown menu)
    - ..\..cegui_head
    - ..\..\cegui_head\include
5.9 We want to reference the CEGUI dir and include directories as well as the WxWidgets ones, so let's use our newly created environment variables. Add the following four lines in both Debug and Release configurations (top-left dropdown menu)
    - $(CEGUI)
    - $(CEGUI)\include
    - $(WXWIDGETS)\include
    - $(WXWIDGETS)\include\msvc
5.10 Navigate to ConfigurationProperties\Linker\General

5.11 Open the Additional Library Directories panel

5.12 Remove the following line, for the same reason as above in both Debug and Release configurations (top-left dropdown menu)
    - ..\..\cegui_head\lib
5.13 Add the CEGUI and WxWidgets lib dirs in both Debug and Release configurations (top-left dropdown menu)
    - $(CEGUI)\lib
    - $(WXWIDGETS)\lib\vc_lib
5.14 Navigate to ConfigurationProperties\Linker\Input

5.15 Replace the following lines (which refer to an older WxWidgets version)
    Debug Configuration

    - wxmsw26ud_core.lib TO wxmsw28ud_core.lib
    - wxbase26ud.lib TO wxbase28ud.lib
    - wxmsw26ud_gl.lib TO wxmsw28ud_gl.lib

    Release Configuration

    - wxmsw26u_core.lib TO wxmsw28u_core.lib
    - wxbase26u.lib TO wxbase28u.lib
    - wxmsw26u_gl.lib TO wxmsw28u_gl.lib
6) CELAYOUTEDITOR INITIAL BUILD ATTEMPT:
-----------------------------------------------------------

Let's try to build our editor. We must first build WxWidgets, since it is a dependency.

6.1 Go to $(WXWIDGETS)\build\msw and open file wx.dsw in VS2005 or VS2003.

6.2 wx.dsw is a VC6 project, so it needs to be converted to VS2005 or VS2003. When prompted, accept the conversion by pressing the 'Yes To All' button.

6.3 Build the WX solution in 'Unicode Debug' and 'Unicode Release' configurations
    NOTE: This may take a while since the solution is quite big

    NOTE2: The Wiki 'Getting Started' entry (http://www.cegui.org.uk/wiki/index.php/Getting_Started) mentions that no unicode is required, however the $(WXWIDGETS)\include\msvc\wx\setup.h references the WXWidgets unicode files
6.4 If you try to build the solution CELayoutEditor just yet, you'll notice that it will produce compile errors such as
    - error C2504: 'wxGLCanvas' : base class undefined d:\dev\ceguitests\celayouteditor\inc\editorcanvas.h 30
The problem lies in the fact that the WxWidgets dependency was built without OpenGL support, which is required for the CELayoutEditor

7) CELAYOUTEDITOR SECOND BUILD ATTEMPT:
--------------------------------------------------------

Let's correct the previous problem and try again.

7.1 Open $(WXWIDGETS)\include\wx\msw\setup.h and replace

Code:
#define wxUSE_GLCANVAS 0
WITH
Code:
#define wxUSE_GLCANVAS 1


7.2 Open $(WXWIDGETS)\include\wx\univ\setup.h and replace

Code:
#if defined(__WIN32__)
   #define wxUSE_GLCANVAS 1
else   
    #define wxUSE_GLCANVAS 0

WITH
Code:
#define wxUSE_GLCANVAS 1

7.3 While we're at it, also check in the previous two files, if the defines wxUSE_EXCEPTIONS and wxUSE_ABOUTDLG are set to 1 (this is the default, so it should be on). This is mandatory and CELayoutEditor will not compile without it.
Code:
#define wxUSE_EXCEPTIONS 1

Code:
#define wxUSE_ABOUTDLG 1

7.4 Rebuild the WX solution in 'Unicode Debug' and 'Unicode Release' configurations.

7.5 Rebuild CELayoutEditor solution. Hoperfully, the build will be successful.

8) RUNNING CELAYOUTEDITOR:
--------------------------------------

IMPORTANT NOTE: As of 05/11/07, the VC++7.1 (VS2003) and VC++8 (VS2005) solutions have post-build steps that take care of the problems enumerated in this section. You should now be able to run the editor without any further problems. This section is kept for reference purposes.

If you try to run the application, errors will popup because the required CEGUI dlls are not present in the executable directory. So, do the following:

8.1 Copy the following files from $(CEGUI)\bin to $(CE_LAYOUT_EDITOR)\bin\debug and/or $(CE_LAYOUT_EDITOR)\bin\release depending on the configuration you are testing
    TO $(CE_LAYOUT_EDITOR)\bin\debug (Debug configuration)
    - CEGUIBase_d.dll
    - CEGUIExpatParser_d.dll
    - CEGUIFalagardWRBase_d.dll
    - CEGUISILLYImageCodec_d.dll
    - CEGUITGAImageCodec_d.dll
    - OpenGLGUIRenderer_d.dll

    TO $(CE_LAYOUT_EDITOR)\bin\release (Release configuration)
    - CEGUIBase.dll
    - CEGUIExpatParser.dll
    - CEGUIFalagardWRBase.dll
    - CEGUISILLYImageCodec.dll
    - CEGUITGAImageCodec.dll
    - OpenGLGUIRenderer.dll
However, even when you copy all of the above files, the following error still refuses to disappear (example for debug file, in release the file changes to CEGUISILLYImageCodec):
    - CELayoutEditor:OnInit - Error: DynamicModule::DynamicModule - Failed to load module 'CEGUISILLYImageCodec_d': The specified module could not be found.
Despite the fact the dll is correctly placed at the executable dir.

8.2 As it turns out, the error message is not correct. As dmail explained (see post below), the GL renderer will dynamically load the the CEGUI SILLY DLL which in turn will load the SILLY DLL. And here lies the problem, since the application cannot find the SILLY DLL in the path. Therefore, the error message should be (for debug builds):
    -CELayoutEditor:OnInit - Error: DynamicModule::DynamicModule - Failed to load module 'CEGUISILLYImageCodec_d': The specified SILLY_d module could not be found.
8.3 Copy SILLY_d.dll and SILLY.dll from $(CEGUI)\dependencies\bin to $(CE_LAYOUT_EDITOR)\bin\debug and $(CE_LAYOUT_EDITOR)\bin\release respectively.

NOTE: You could also change the used image codec by opening EditorFrame.cpp in CELayoutEditor and replacing the following line

Code:
CEGUI::OpenGLRenderer::setDefaultImageCodecName("SILLYImageCodec");

BY
Code:
CEGUI::OpenGLRenderer::setDefaultImageCodecName("TGAImageCodec");


8.4 You'll notice one final error when running the editor: Missing splash screen. To solve it, copy $(CE_LAYOUT_EDITOR)\src\bitmaps\splash.png to $(CE_LAYOUT_EDITOR)\bin\debug or $(CE_LAYOUT_EDITOR)\bin\release depending on the configuration you're building the editor in.

8.5 Rebuild CELayoutEditor and run it. Everything seems OK now.

I hope you liked this little guide. Let me know what you think.

posted on 2008-01-01 00:23 杨粼波 阅读(4192) 评论(1)  编辑 收藏 引用

评论

# re: CELayoutEditor编译详尽步骤 2010-02-03 15:17 senlin

thanks  回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理