Page 1 of 3

MinGW environment for building OpenTTD

Posted: 12 Apr 2006 20:34
by LKRaider
Hi there :)

I documented a step-by-step guide to get a working build environment to compile SVN OpenTTD on Windows. If you ever wanted to do it, but didn't know how, here is your chance :wink:

So, here we go:


Download needed files:
Install the packages:
Install MSYS:
Folder: X:\msys (remove the 1.0 thing, it's useless)
Questions: Answer "no" when it asks about MinGW, we'll install it next.

Install MinGW:
Preparation: First copy the mingw.ini file to the folder where the MinGW setup program is, then execute the setup.
Folder: X:\msys\mingw (replace X: with a real drive letter)
Questions: Select Candidate, then select the Minimal install plus the g++ compiler.

Install SVN:
Details: Just unzip it to the folder below.
Folder: X:\msys\home\YourUser (replace with the name of your user there)

Install EnvSetup:
Folder: X:\msys\home\YourUser (same as before)

Okay, installations are complete, now let's setup the compilation environment.



Setup Compilation:

> Start MSYS : msys.bat

Run these commands, one by one:

Code: Select all

./build\ requirements.sh
  • This will build the required libraries (zlib, libpng, and copy dx9 files)

Code: Select all

./get\ latest\ openttd.sh
  • This will download the latest OpenTTD code from SVN. You can run it anytime later on, to always have the most up-to-date code from the net

Code: Select all

cd ../OpenTTD/trunk
  • Change to OpenTTD build directory

Code: Select all

./configure --with-png --with-directmusic
  • Configure compilation

Code: Select all

notepad Makefile.config
  • This will open the file that configures the compilation for manual edit, we will change a few lines.
    Edit the corresponding lines to look like this:

Code: Select all

INSTALL:=1
PREFIX:=home/OpenTTD
BINARY_DIR:=build
DATA_DIR:=build
ICON_DIR:=build
USE_HOMEDIR:=
PERSONAL_DIR:=/home/OpenTTD/build
SECOND_DATA_PATH:=data
CUSTOM_LANG_PATH:=lang
  • Save and close Notepad. We are ready to compile.

Compile:
Back on MSYS, execute:

Code: Select all

make && make install && make clean
  • and wait! :) When done, you'll have the new compiled files at OpenTTD\build, looking just like a nightly release !
From here on, it's with you. Mess with the code, see if it compiles, etc. Have fun 8)

Also, for applying patches, you may like to try TortoiseSVN. It also will let you administer the OpenTTD SVN folder through Windows Explorer.

NOTE: I did my best to test the correctness of these instructions, but it is quite possible something has evaded my sight, so if you face problems while following them, please post them here and I will try to correct the guide.

Posted: 12 Apr 2006 20:43
by DaleStan
*reads name*
*rubs eyes*
*re-reads name*
*rubs eyes again*
*re-re-reads name*
Yep. It does indeed say LKRaider.

Welcome back.

Posted: 12 Apr 2006 20:55
by XeryusTC
The MinGW documentation/installation guide said that it is better to install MinGW before MSys, of course you don't have to listen to this advice ;).

Posted: 12 Apr 2006 20:55
by LKRaider
Thanks DaleStan : ) Yeah, I've been away for some time... heh


I prefer the MSYS then MinGW install method here, simply because there is no need to type the location of MinGW when installing MSYS, which makes it easier (for lazy people like me :P ). And since we are installing inside /mingw , we need no fstab entry for it anyways.

Posted: 12 Apr 2006 22:03
by TrueBrain
Please update the wiki about this topic. There is already a patch about how to compile on mingw, but I believe it is a bit outdated. Nice job btw ;)

Posted: 12 Apr 2006 23:35
by MeusH
Thanks! That's what I've been looking for since MSVC++ strangely crashes when loading langs.dsp...

Posted: 13 Apr 2006 16:40
by LKRaider
TrueLight: you mean, replace the whole instructions there or just update it a bit? Also, should it really include the EnvSetup I'm using here?

I think the wiki should stay more generic, simply because the EnvSetup will need to be updated manually for new versions of zlib and pnglib (and I'm also using the mingwPORT patches here, slightly edited for automation).

The only thing missing in the wiki, is about DirectX, though they are mentioned for Dev-C++. (note: here I use DX9c SDK files, not the ones mentioned at the Dev-C++ page).

I'll edit it a bit, see how you like it.

Posted: 13 Apr 2006 17:08
by MeusH
Horray! It works :bow: Thank you so much!
No more MSVC++, that's just great :)

MinGW is small and simple yet powerful tool, indeed

Posted: 13 Apr 2006 18:04
by LKRaider
Good to hear it works for you :D

I like the MinGW and MSYS tools too, yep simple and powerful. : )

Posted: 15 Apr 2006 04:07
by LKRaider
Double post, but... is there a place I can upload files to be attached on the wiki?

The wiki upload feature only allows pictures, and on the forums you need to rename the files, which only complicates the wiki instructions further.

Any ideas?

Posted: 15 Apr 2006 05:16
by DaleStan
zip? rar? tar.gz? tar.bz2? Talk to SROTU™ about a users.tt-forums.net account?

Posted: 15 Apr 2006 13:14
by habell
I've a question. I've followed de installation guide to the letter but for some reasen it can't find svn when I start msys.

When I type: svn, it can't find it.
When I type: ./bin/svn it can.

So it seems to have something todo with path settings. But where can I find them?

Because:

Code: Select all

./configure --with-png --with-directmusic
doesn't work, when it can't find svn.

Please help.

Posted: 15 Apr 2006 14:13
by Darkvater
Weird, SVN should be in your path. what does 'echo $PATH' say?

You can set your path to include svn by doing 'export PATH=$PATH;/bin'

Posted: 15 Apr 2006 17:21
by habell
Darkvater wrote:Weird, SVN should be in your path. what does 'echo $PATH' say?

You can set your path to include svn by doing 'export PATH=$PATH;/bin'
Thanks, it works now :D

Posted: 17 Apr 2006 13:09
by orudge
DaleStan wrote:zip? rar? tar.gz? tar.bz2? Talk to SROTU™ about a users.tt-forums.net account?
Indeed, can you not stick it in a zip file and tell the user to unzip it? One would assume that if they're planning on building code, they can unzip a file. :)

Posted: 17 Apr 2006 15:13
by MeusH
LKRaider, could you please explain
make && make install && make clean?
I assume make compiles code, make install creates binary files in ../build/, and make clean removes some temp files, but I'm not very sure.

Posted: 17 Apr 2006 15:52
by gigajum
MeusH wrote:LKRaider, could you please explain
make && make install && make clean?
I assume make compiles code, make install creates binary files in ../build/, and make clean removes some temp files, but I'm not very sure.
make <- compiles all stuff
make install <- copies all generated and needed files to a folder, set by configure or a default dir
make clean <- removes all compiled things and cleans the dir as nothing had done with the files

Posted: 17 Apr 2006 19:47
by LKRaider
MeusH : yep, that's pretty much it.

I use the three steps so you have the compiled code in the build folder, and the source code separated and clean from temp files when you are done compiling.

Usually, if you do not setup the make install step, you have to manually copy the compiled stuff out of the source tree before performing a make clean, as it will delete the compiled files too.

All others : Ah yes! .zip! :P My mind fails to find obvious solutions like that sometimes, heh.
I was thinking of uploading to the wiki, but putting on the forums is ok too, I guess.

Posted: 19 Apr 2006 16:41
by PAStheLoD
Hi!

This looks very-very..-very promising, however, because of my user name being two words separated by a space (it's 'Lord Pas') and that nasty space causes me a lot of trouble..

so is there a way, to force msys to use another directory as home dir?

Thanks in advance :)

edit:

hm, I've figured it out.. etc/profile -> just hardcode the LOGNAME, HOME USERNAME vars to a directory whose name doesn't contain space, and go on ;]

Posted: 19 Apr 2006 16:45
by Sacro
remove the space in the /home/what\ ever/ folder and then also change it under /etc/passwd , works for me under cygwin