celestar@5592: Compiling OpenTTD using Microsoft Visual C++ rubidium@5645: January 2, 2007 celestar@5592: -------------------------------------------- celestar@5592: PLEASE READ THE ENTIRE DOCUMENT BEFORE DOING ANY ACTUAL CHANGES!! darkvater@844: rubidium@5645: celestar@5592: SUPPORTED MSVC COMPILERS celestar@5592: ------------------------ celestar@5592: OpenTTD includes projects for MSVC 2003.NET and MSVC 2005.NET. Both will celestar@5592: compile out of the box, providing you have the required libraries/headers; celestar@5592: which ones, see below. There is no support for VS6, you are therefore celestar@5592: strongly encouraged to either upgrade to MSVC 2005 Express (free) or use GCC. celestar@5592: MSVC 2002 probably works as well, but it has not been tested. darkvater@844: rubidium@5645: celestar@5592: 1) REQUIRED FILES celestar@5592: ----------------- celestar@5592: You might already have some of the files already installed, so check before celestar@5592: downloading; mostly because the DirectX SDK and Platform SDK are about celestar@5592: 500MB each. miham@940: Download the following files: darkvater@844: celestar@5592: * openttd-useful.zip (http://sf.net/project/showfiles.php?group_id=103924&package_id=114307) celestar@5592: * DirectX 8.1 SDK (http://neuron.tuke.sk/~mizanin/eng/Dx81sdk-include-lib.rar) (or alternatively the latest DirectX SDK from Microsoft) celestar@5592: * MS Windows Platform SDK (http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en) celestar@5592: * afxres.h (http://www-d0.fnal.gov/d0dist/dist/packages/d0ve/devel/windows/AFXRES.H) miham@940: Darkvater@2771: ...and of course the newest source from svn://svn.openttd.org/trunk miham@940: celestar@5592: You need an SVN-client to download the source from subversion: miham@940: celestar@5592: * CLI Subversion (http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91) celestar@5592: * GUI TortoiseSVN (http://tortoisesvn.tigris.org/download.html) miham@940: rubidium@5645: celestar@5592: 2) INCLUDES AND LIBRARIES celestar@5592: ------------------------- celestar@5592: Put the newly downloaded files in the VC lib\ and include\ directories; where celestar@5592: "C:\Program Files\Microsoft Visual Studio 8\VC" is your location of Visual C. celestar@5592: If you are compiling for an x64 system, use the include\ and lib\ directories celestar@5592: from the win64/ folder. miham@940: celestar@5592: * openttd-useful.zip\include\* celestar@5592: * afxresh.h celestar@5592: to > C:\Program Files\Microsoft Visual Studio 8\VC\Include miham@940: celestar@5592: * openttd-useful.zip\lib\* celestar@5592: to > C:\Program Files\Microsoft Visual Studio 8\VC\Lib miham@940: celestar@5592: Custom directories might be recommended, check 2.2) miham@940: miham@940: celestar@5592: 2.1) INCLUDES AND LIBRARIES - DIRECTX/PLATFORM SDK celestar@5592: -------------------------------------------------- celestar@5592: Basically the same procedure as with the useful zip file, providing celestar@5592: you are not using the Microsoft installer. Put the include files in the celestar@5592: include\ directory and the library files to the Lib\ directory. miham@940: celestar@5592: It is recommended to use custom directories so you don't overwrite any celestar@5592: default header or library files. miham@940: rubidium@5645: celestar@5592: 2.2) CUSTOM DIRECTORIES celestar@5592: ----------------------- celestar@5592: If you have put the above include and/or library files into custom folders, celestar@5592: MSVC will not find them by default. You need to add these paths to VC through: miham@940: celestar@5592: Tools > Options > Projects and Solutions > VC++ Directories > show directories for miham@940: celestar@5592: * Include files: Add the DirectX/Platform SDK include dir you've created celestar@5592: * Library files: Add the path to the SDK custom lib dir celestar@5592: celestar@5592: NOTE: make sure that the directory for the DirectX SDK is the first one in the celestar@5592: list, above all others, otherwise compilation will most likely fail!! celestar@5592: rubidium@5645: rubidium@5645: 2.3) DEBUGGING - WORKING DIRECTORY (MSVC 2003 ONLY!) rubidium@5645: ---------------------------------------------------- rubidium@5645: The very first time you check out and compile OpenTTD with Visual Studio 2003, running rubidium@5645: the binary will complain about missing files. You need to go into and change a setting rubidium@5645: rubidium@5645: OpenTTD > Project > Properties > Configuration (All Configurations) > ... rubidium@5645: Configuration Properties > Debugging > rubidium@5645: rubidium@5645: * Working Directory: ..\bin rubidium@5645: rubidium@5645: VS 2005 works out of the box because Microsoft allowed a user to supply a humanly- rubidium@5645: readable defaults file (openttd_vs80.vcproj.user), whereas 2003 is braindead. rubidium@5645: rubidium@5645: celestar@5592: 3) TTD GRAPHICS FILES celestar@5592: --------------------- rubidium@5645: Copy the following files from Transport Tycoon Deluxe to the bin/data folder miham@940: celestar@5592: * sample.cat celestar@5592: * trg1r.grf celestar@5592: * trgcr.grf celestar@5592: * trghr.grf celestar@5592: * trgir.grf celestar@5592: * trgtr.grf miham@940: miham@940: celestar@5592: 4) COMPILING celestar@5592: ------------ celestar@5592: Open trunk/openttd[_vs80].sln celestar@5592: Set the build mode to 'Release' in celestar@5592: Build > Configuration manager > Active solution configuration > select "Release" miham@940: Compile... miham@940: rubidium@5645: If everything works well the binary should be in trunk/objs/[Win32]/Release/openttd.exe rubidium@5645: Darkvater@2771: celestar@5592: 5) EDITING, CHANGING SOURCE CODE celestar@5592: -------------------------------- celestar@5592: Set the build mode (back to) 'Debug' celestar@5592: Change the startup project to openttd by right-clicking the 'openttd' project celestar@5592: in the Solution Explorer and selecting 'Set as Startup Project'. The 'openttd' celestar@5592: project should now show up bold instead of 'strgen'. darkvater@844: rubidium@5645: celestar@5592: 6) PROBLEMS? celestar@5592: ------------ celestar@5592: If compilation fails, double-check that you are using the latest SVN (!) celestar@5592: source. If it still doesn't work, check in on IRC (irc://irc.oftc.net/openttd), celestar@5592: to ask about reasons; or just wait. The problem will most likely solve itself celestar@5592: within a few days as the problem is noticed and fixed. darkvater@844: celestar@5592: An up-to-date version of this README can be found on the wiki: celestar@5592: http://wiki.openttd.org/index.php/MicrosoftVisualCExpress