Compiling OpenTTD - What Am I Missing?

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

FreakAZoid
Engineer
Engineer
Posts: 11
Joined: 12 Mar 2010 01:29

Compiling OpenTTD - What Am I Missing?

Post by FreakAZoid »

Hello!

Over the last few days I've been browsing the forums to learn how to compile OpenTTD. My goal is to use Bilbo's extra-large-maps patch to test a DEM of the Caucasus region.

I have been able to use TortoiseSVN to download the latest files and use Visual C++ 2008 Express Edition to compile the source files minus any patches. I've discovered some errors that I have found solutions for and I think once I get these worked out, I'll be in good shape. I have found several "how to" guides that have basically spelled out everything except one thing.

Once I have successfully compiled, what do I do next?

I think I'm supposed to take the compiled files/folders and overlay them over a previously-installed version of OpenTTD? Either I'm not searching the forums correctly for this information or it's right in front of me and I'm just being my normal self. I had been running RC2 with the NoMusic option flawlessly since it was available for download, but I uninstalled it and created a clean environment thinking the compile would be sufficient to play the game.

I have OpenGFX and OpenSFX downloaded, as well as RC2 and 0.7.5 and the Bilbo patch. I also have an original TTD CD-ROM. And I am doing this on a clean XP partition with XP SP3; my basic hardware is a Kuma 7850 with 4GB of RAM.

I apologize for making what could be a bone-headed first post here, but I'm stumped. :oops:
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Compiling OpenTTD - What Am I Missing?

Post by Yexo »

FreakAZoid wrote:Once I have successfully compiled, what do I do next?
You have several options.
1. You can run it directly from MSVC (Debug->Start debugging)
2. You can create a bundle first. To do this you'll need either cygwin or msys/mingw. If you have either just cd to the source directory and then do "make -f Makefile.msvc bundle". Instead of "bundle" you can also use "bundle_zip" or even some other formats. Bundle will copy all needed files to the directory bundle/. Bundle_zip does the same but also creates a zip file from the bundle directory.

In both cases you'll still need a base grahpics, sound and music set. If you put them in My Documents/OpenTTD/data/ then they can be found by all your OpenTTD installations.
FreakAZoid
Engineer
Engineer
Posts: 11
Joined: 12 Mar 2010 01:29

Re: Compiling OpenTTD - What Am I Missing?

Post by FreakAZoid »

OK! I will try the first option as soon as I'm back up and running on this partition.
FreakAZoid
Engineer
Engineer
Posts: 11
Joined: 12 Mar 2010 01:29

Re: Compiling OpenTTD - What Am I Missing?

Post by FreakAZoid »

Success! I am now running OpenTTD in a Debug window and have identified the two problems I previously had.

#1: I forgot to install the DirectX SDK. :oops:

#2: When I ran SVN, it download files but did not present me with any Solution files. After pondering this for awhile, I realized I had not downloaded the source files themselves into the folder. After doing this, I did a Checkout and I am now being told I'm running at r19389. I assume this is correct, because I ran my build and there I was, staring at the titles screen.

This has produced an additional question.

* When I installed and played TTDPatch on my main machine, I had, at some point, copied the game folder to a flash drive. I don't remember specifically copying anything other than the folder and its included subfolders. When I got to work, I copied the folder from the flash drive to my work computer and it actually executed. I played for about an hour over several days without any difficulty. I do not remember doing an actual install of anything because I do not have admin rights on that machine (Vista Business) but the game is playable nonetheless.

Is it possible to do the same thing with OpenTTD? I mean, judging by what I just did with my first working compile, I don't see why I couldn't, but I have MSVC on this machine, something I would not be allowed to install at work. It would be nice to play during my down time, and so long as it could be done without needing admin rights, it's fair game.


Thanks for the pointers, Yexo!
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: Compiling OpenTTD - What Am I Missing?

Post by ChillCore »

Yes, you can copy the game to for example an usb stick.
You just have to make sure that you copy everything from the bin folder.
Do mind that on the other pc you will not have a shared folder so you have to put the OpenGFX, OpenSFX and OpenMSX files in that data folder. (Or the original files as you have the original game) Also the openttd.cfg should be placed in this folder.
You can then play directly from the usb stick without having to install the game to the other pc.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
FreakAZoid
Engineer
Engineer
Posts: 11
Joined: 12 Mar 2010 01:29

Re: Compiling OpenTTD - What Am I Missing?

Post by FreakAZoid »

@ChillCore
I will try that tomorrow!

I have found another question. It's been 15+ years since I wrote code, so I'm beyond rusty with this kind of stuff.

I can't get the patch to work in RC1 or RC2. So I did some looking around and got a better understanding of the "r" designation. Bilbo's patch is r19000, which appears to be the base version of Beta 4. RC1 seems to start a lot higher, and I can't get it to patch. I would assume, based upon several other threads I've read, that increasing from r19000 to r19001 could possibly be enough for any patch to fail, depending on what the new "r" code may have added to the entire environment. Is this correct?

I must admit, I haven't actually loaded a game tonight, and I'm still having fun.
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: Compiling OpenTTD - What Am I Missing?

Post by ChillCore »

Your assumption is correct.
Have a looksie here to see what changed where and why:
http://vcs.openttd.org/svn/

If you know there is a conflict, I suggest bumping, with the patch applied, by a few revisions at a time starting from the revision the patch was made.
If the patch is not to big you can also try to apply it manually directly to the revision you want it to be.
If you can find the exact code that has to be replaced, just replace it. If you can not find it you can in most cases figure it out by looking at the code in the patch and comparing the "-" with what is actually there.

note:
In most cases Turtoise will tell you there is a conflict while you are bumping, but sometimes it doesn't. Again depending on what changed where.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
FreakAZoid
Engineer
Engineer
Posts: 11
Joined: 12 Mar 2010 01:29

Re: Compiling OpenTTD - What Am I Missing?

Post by FreakAZoid »

Success!

The patch chokes on the current nightly. However, with r19000 I have a 4096 x 64 map running in Debug mode. And I can see the higher map sizes in the options. I will now try bumping to see where the patch breaks.

I'm sure there will be a couple of more questions, but no more for tonight. Thanks to both for your help. :)

~Zoid
FreakAZoid
Engineer
Engineer
Posts: 11
Joined: 12 Mar 2010 01:29

Re: Compiling OpenTTD - What Am I Missing?

Post by FreakAZoid »

OK, new problem. Tried searching the "error code" but didn't get a hit.

This is what my MinGW screen looks like...


FreakAZoid@ATHLON7850 ~
$ cd /c/y

FreakAZoid@ATHLON7850 /c/y
$ make -f Makefile.msvc bundle
cp: cannot stat `objs//Release/openttd.exe': No such file or directory
make: *** [all] Error 1


And this didn't work either.

$ make -f Makefile.msvc bundle platform=win32
cp: cannot stat `objs//Release/openttd.exe': No such file or directory
make: *** [all] Error 1


I did read this, and so far as I can tell, I think I've got everything right...
http://wiki.openttd.org/?title=Microsof ... ldid=35195

My build is in the c:\y\ folder.
Last edited by FreakAZoid on 13 Mar 2010 04:12, edited 1 time in total.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Compiling OpenTTD - What Am I Missing?

Post by Yexo »

Ah, I forgot something. Try

Code: Select all

make -f Makefile.msvc bundle PLATFORM=Win32
Replace Win32 with Win64 if you've build a 64bit binary.
FreakAZoid
Engineer
Engineer
Posts: 11
Joined: 12 Mar 2010 01:29

Re: Compiling OpenTTD - What Am I Missing?

Post by FreakAZoid »

I did. The edit to my last post did not beat your response. :!:

FreakAZoid@ATHLON7850 /c/y
$ make -f Makefile.msvc bundle PLATFORM=Win32
cp: cannot stat `objs/Win32/Release/openttd.exe': No such file or directory
make: *** [all] Error 1
FreakAZoid
Engineer
Engineer
Posts: 11
Joined: 12 Mar 2010 01:29

Re: Compiling OpenTTD - What Am I Missing?

Post by FreakAZoid »

I'm done! :mrgreen:

I think I misunderstood the purpose of the bundle. After I started hunting around I discovered an OpenTTD.exe file in the C:\Y\OBJS\WIN32\DEBUG folder. I copied it into the C:\Y\BIN folder and it executed fine. What I was really trying to do was create an executable that would run outside of the Debug window, and it seems I've done that, so mission accomplished.

I have a Word 2007 file that consolidates all of these processes I've discovered into instructions I could understand six months from now. I intend to upload some screenshots into it so n00bs like myself have a step-by-step instruction manual for doing what I just did: compiling OpenTTD from start to finish with a patch and setting it up to run on removable or non-removable media. If I wanted to offer it here, how would I make it web-friendly? I do most of my work in Word 2007 and/or Adobe Acrobat 9.
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Compiling OpenTTD - What Am I Missing?

Post by petert »

Yexo wrote:Replace Win32 with Win64 if you've build a 64bit binary.
That would be if the directory is /objs/win64, but it is /objs/x64, so it would look in the wrong directory (pointed out to me by neob).
FreakAZoid
Engineer
Engineer
Posts: 11
Joined: 12 Mar 2010 01:29

Re: Compiling OpenTTD - What Am I Missing?

Post by FreakAZoid »

I was not able to make the bundle. I don't know if I've got a bad installation of something or not. I tried the same process on two different machines and I'm getting the same error; it has to be user error on my part.

The only thing I'm wondering about is the notation regarding the /Win32 subfolder. When a bundle is created successfully, what files does it actually create, and where exactly will those files end up? The error message makes me think it's not finding/creating a target directory. I do have a \DEBUG subfolder within the \Win32 which contains a ton of object files and the openttd.exe file (I assume these are created as a result of compiling the code). But there is no other folder within \Win32.

I'd like to solve this mystery, but I'm certainly in no rush.

My C:\Y\ folder is 229MB. Is that unusual after compiling r19000? It seems kind of large...
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Compiling OpenTTD - What Am I Missing?

Post by Yexo »

You can create to types of binaries with MSVC: debug binaries and release binaries. Apparently the default is a debug binary as that's what you've been doing. A debug binary makes debugging a crash easier but is also a lot slower then a release binary. "make bundle" (see previous post for full command) only works if you've build a release binary.
My C:\Y\ folder is 229MB. Is that unusual after compiling r19000? It seems kind of large...
Not at all, the object files add up quickly and there are a lot of them.
FreakAZoid
Engineer
Engineer
Posts: 11
Joined: 12 Mar 2010 01:29

Re: Compiling OpenTTD - What Am I Missing?

Post by FreakAZoid »

OK, I think I got it.

I started with fresh partition and installed the necessary software, downloaded r19000 and patched with Bilbo's patch and compiled it as a release solution. I was left with C:\XLR as my test directory.

I ran the following command from MSYS at /c/xlr:
make -f Makefile.msvc bundle PLATFORM=Win32

This time, I got an error:
/bin/sh.exe unix2dos.exe command not found

But...there is now a folder called \BUNDLE with what looks like the correct directory structure for an OpenTTD installation and includes an openttd.exe executable. I clicked on it and I'm now in OpenTTD r19000.

Do I now have a binary?
Eddi
Tycoon
Tycoon
Posts: 8272
Joined: 17 Jan 2007 00:14

Re: Compiling OpenTTD - What Am I Missing?

Post by Eddi »

FreakAZoid wrote:This time, I got an error:
/bin/sh.exe unix2dos.exe command not found
this is not essential, it only converts the readme and stuff so it can be opened with notepad, which does not handle unix line endings.
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Compiling OpenTTD - What Am I Missing?

Post by petert »

FreakAZoid wrote:Do I now have a binary?
Yes, nice job!
FreakAZoid
Engineer
Engineer
Posts: 11
Joined: 12 Mar 2010 01:29

Re: Compiling OpenTTD - What Am I Missing?

Post by FreakAZoid »

So happy!!! :bow:


My next project is to apply Bilbo's patch to a nightly. Which do you think would be the most advantageous approach to take?


1) Hey everyone! Great game! I want to use Bilbo's patch on the latest nightly, but I'm too busy to take the time to learn the basics and would rather have someone spoon-feed me what I need and to hell with the community collaboration concept. Could someone compile the latest nightly with Bilbo's patch and upload it here? TIA!

2) I really don't understand any of this, so could someone please tell me how to do it? Now?

3) If I don't have access to an educational facility that teaches programming, is it realistic to think I could buy a 500-page Sybex-type "Learn C" book and learn enough of the basics to start fiddling with the OpenTTD code? Are there other sources I could pursue that would help?


I've always enjoyed starting flame wars with option 1. On a bad day, I would just ban users who pursued option 2. So yes, I do understand there is a certain level of frustration here when people behave like that, or aren't willing to use the "Search" function and maybe spend enough time to ask questions that show you at least tried. Option 3 seems to be reasonable, but before I shell out quid for print, I wanted to make sure it's a realistic approach.


~Zoid
User avatar
Muzzly
Traffic Manager
Traffic Manager
Posts: 226
Joined: 09 Jun 2010 20:54
Location: Vilnius, LT

Re: Compiling OpenTTD - What Am I Missing?

Post by Muzzly »

I have some compilation erros with minGW.

what for is option "-lintl". What kind of library is it for ?
./configure creates a \objs\release\Makefile with LIBS flag set to:
= -lstdc++ -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32 /usr/local/lib/libz.a /usr/local/lib/liblzo2.a -Ld:/msys/lib -Ld:/msys/lib -lfreetype -lz -Wl,-s -LD:/Progra~1/GnuWin32/lib -lintl -lwsock32 -lole32 -luuid -lmsvcp60

It seems that this "-lintl" cause linking error. If I disable it, then I can link openttd.exe.
With this flag I get following error:

Code: Select all

[SRC] Linking openttd.exe
d:\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lintl
collect2: ld returned 1 exit status
make[1]: *** [openttd.exe] Error 1
Is it ok, to Link openttd wihtout "-lintl" flag ?
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 45 guests