Page 1 of 4
Compiling OpenTTD
Posted: 01 Jun 2006 05:58
by Sebastiaan
I'm trying to get a working compiling and editing environment up so that i could give a go at a patch of my own.
I managed to get TortoiseSVN up and it actually got the source of the trunk for me
However, compiling using Visual C++ 2005 Express seems not to be as easy.
Encountered error is the following:
c:\documents and settings\sebastiaan\my documents\openttd\source\svn\stdafx.h(172) : fatal error C1083: Cannot open include file: 'endian_target.h': No such file or directory
I suppose I'm missing some file.. so i looked for it on google to find which package it could be... and ended up here on the openTTD general forum with no usefull info at all.
I DID install the files from usefull.zip to the respective Microsoft Visual Studio 8\VC directories as suggested on the wiki. However, that zip does not contain an endian_target.h file...
While I'm at it:
Question 2
While adding all files to be found in the SVN directory, VCE said it found an .asm file containing special build rules. i couldn't click ok so i clicked cancel. should that have been a problem?
Question 3
Is it good practice to make a patch against the SVN Trunk or should i make it against another version?
Thanks for any suggestion for this c newbie

Posted: 01 Jun 2006 06:38
by XeryusTC
Question 2 is the problem of your first question, those custom build rules make endian_target.h before compiling everything.
Question 3: You should make it against the trunk, it will be appliable to most of the branches too, although it sometimes requires some editing.
Posted: 01 Jun 2006 07:27
by Darkvater
You don't/shouldn't need endian_target.h. All you should do is open openttd.sln which will get automatically read and updgraded with VS2005 and you're set to go.
Posted: 01 Jun 2006 10:09
by Sebastiaan
Thanks, i made it
Will update the wiki a bit so that the next one attempting this will have less trouble...
[EDIT] Apparently i will not, because it is not possible to edit the page on development tools to add a section on the Visual C++ 2005 Express part...
For those looking for help searching the forum i'll then simply post a summary here:
1) Download & install
Visual C++ 2005 Express (from Mircrosoft, free)
2) Follow the instructions on this page for the
Microsoft Platform SDK (start with step 2, you did step 1 already)
I have used the April 2005 edition to which the link on this page and it works. If you prefer newer versions you can follow the links to related software and install a newer one. No guarantees on that one though
3) Download the following usefull stuff:
Usefull libs for Openttd,
DirectX 8.1 SDK and
afxres.h.
Installation instructions for these can be found on the
wiki, step 2[/list]
4) Open VCExpress and go to tools -> options -> Projects and Solutions -> VC++ Directories and add the directories of the includes and libs that you added in step 3.
5) Use
SVN to obtain a copy of the SVN source (i gave a link to TortoiseSVN, which i must say is really easy to use) (In a nutshell: install, create a directory, right click- svn update, enter link, ready
6) Locate the file openttd_vs80.sln in the main SVN folder and double click it. It will open VCE and you are ready to compile. Press F7.
Executables appear under Debug folder or, if you select release in 'build -> configuration manager', in the Release folder.
Have fun.
Thanks To DarkVater, Hazelrah and XeryusTC for helping me out!
Posted: 01 Jun 2006 15:43
by sidew
Thanks for the advice. With the introduction of yapf in trunk, i can't compile anymore with MSVC6....

So i 'm starting looking for an another IDE.
Next week, when I get my new notebook I'm thinking to get Eclipse and the necessary plug-ins for compiling C/C++, so with one IDE I can develop Java, PHP and C/C++. I don't known that VS2005 express can be get from M$ for free, thanks for noted this.
Posted: 02 Jun 2006 04:58
by Hazelrah
Just a little tidbit of information that I don't see in this thread yet.
openttd.sln is for Visual Studio 2003 (VS 7.x)
The project files have already been upgraded and renamed, so anybody using Visual Studio 2005 (VS 8.0) should open this soluction file:
openttd_vs80.sln
Happy patching!
-Hazelrah
Posted: 02 Jun 2006 05:07
by Sebastiaan
that explains why i had to convert that file before continuing.. i'll update the guide
thankx
Posted: 02 Jun 2006 06:53
by Hazelrah
Glad to help!
BTW, I suggest that you create your wiki page the way that you want, then add a comment on the discusion page that the link in the compile section should be updated to your page. Hopefully someone with access to the page will take a notice.
-Hazelrah
Posted: 02 Jun 2006 10:01
by Sebastiaan
Made it

See link in signature...
Have another question though. I now created the page by making a link to the has-to-be-created-page in the sandbox and then starting editing that page after clicking on the link... is there a nicer way to add a new page to the wiki? cause I've been searching for half an hour for a nice 'create new page' button or link before finally giving up...
Posted: 02 Jun 2006 15:59
by Hazelrah
Yeah, in the search bar, enter the title of the new page, and click go. IE "Not A Real Page". This will appear.
There is no page titled ":Not A Real Page". You can create this page.
For more information about searching OpenTTD, see Searching OpenTTD.
Showing below up to 20 results starting with #1.
The text "You can create this page." is a link to edit your new page.
-Hazelrah
Posted: 02 Jun 2006 16:51
by Sebastiaan
cool, thanks!

Posted: 02 Jun 2006 22:29
by penticrack
some1 compiled with cygwin? it will be compiled , till the end then make ends with a lot errors, like
Code: Select all
window.c:(.text+0x2a4e): undefined reference to `_last_window'
window.c:(.text+0x2a9a): undefined reference to `IConsoleResize'
window.c:(.text+0x2afe): undefined reference to `_last_window'
window.o: In function `MouseLoop':
window.c:(.text+0x2454): undefined reference to `PlaceObject'
window.o: In function `UpdateWindows':
window.c:(.text+0x2629): undefined reference to `DrawMouseCursor'
video/dedicated_v.o:dedicated_v.c:(.text+0x32d): undefined reference to `_Update
Windows'
video/null_v.o:null_v.c:(.text+0x90): undefined reference to `_UpdateWindows'
subsidiaries_cmd.o:subsidiaries_cmd.c:(.text+0x198): undefined reference to `_In
validateWindow'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0x663): undefined reference to `_Is
WindowOfPrototype'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0xc34): undefined reference to `_Al
locateWindowDescFront'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0xc94): undefined reference to `_Al
locateWindowDescFront'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0x12db): undefined reference to `_D
eleteWindowById'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0x136d): undefined reference to `_D
eleteWindowById'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0x1538): undefined reference to `_A
llocateWindowDescFront'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0x15ba): undefined reference to `_A
llocateWindowDescFront'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0x1604): undefined reference to `_A
llocateWindowDescFront'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0x1b9): undefined reference to `_De
leteWindowById'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0x3a9): undefined reference to `_De
leteWindowById'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0x625): undefined reference to `_Se
tWindowDirty'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0x6e5): undefined reference to `_De
leteWindowById'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0xb2c): undefined reference to `_De
leteWindowById'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0xd3f): undefined reference to `_Se
tWindowDirty'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0x10c8): undefined reference to `_D
eleteWindowById'
subsidiaries_gui.o:subsidiaries_gui.c:(.text+0x15ec): undefined reference to `_A
llocateWindowDescFront'
ai/default/default.o:default.c:(.text+0x777): undefined reference to `_Invalidat
eWindow'
ai/default/default.o:default.c:(.text+0x2921): undefined reference to `_GetTileS
lope'
ai/default/default.o:default.c:(.text+0x2c6c): undefined reference to `_GetTileS
lope'
ai/default/default.o:default.c:(.text+0x3340): undefined reference to `_GetTileZ
'
ai/default/default.o:default.c:(.text+0x336d): undefined reference to `_GetTileS
lope'
ai/default/default.o:default.c:(.text+0x342d): undefined reference to `_GetTileS
lope'
ai/default/default.o:default.c:(.text+0x3623): undefined reference to `_GetTileS
lope'
ai/default/default.o:default.c:(.text+0x4f2c): undefined reference to `_GetTileS
lope'
ai/default/default.o:default.c:(.text+0x57d0): undefined reference to `_GetTileZ
'
ai/default/default.o:default.c:(.text+0x57fd): undefined reference to `_GetTileS
lope'
ai/default/default.o:default.c:(.text+0x58be): undefined reference to `_GetTileS
lope'
ai/default/default.o:default.c:(.text+0x5a50): undefined reference to `_GetTileS
lope'
ai/default/default.o:default.c:(.text+0x71c2): undefined reference to `_Invalida
teWindow'
ai/default/default.o:default.c:(.text+0x8c37): undefined reference to `_DeleteWi
ndowById'
ai/trolly/pathfinder.o:pathfinder.c:(.text+0xe70): undefined reference to `_GetT
ileSlope'
ai/trolly/pathfinder.o:pathfinder.c:(.text+0xf7a): undefined reference to `_GetT
ileSlope'
ai/trolly/pathfinder.o:pathfinder.c:(.text+0x14ee): undefined reference to `_Get
TileSlope'
ai/trolly/pathfinder.o:pathfinder.c:(.text+0x1507): undefined reference to `_Get
TileSlope'
ai/trolly/trolly.o:trolly.c:(.text+0x2f14): undefined reference to `_GetTileSlop
e'
unix.o:unix.c:(.text+0x1db): undefined reference to `_ttd_strlcpy'
unix.o:unix.c:(.text+0x209): undefined reference to `_str_validate'
unix.o:unix.c:(.text+0x39a): undefined reference to `_ttd_strlcpy'
unix.o:unix.c:(.text+0x458): undefined reference to `_ttd_strlcpy'
unix.o:unix.c:(.text+0x479): undefined reference to `_ttd_strlcpy'
unix.o:unix.c:(.text+0x481): undefined reference to `_str_validate'
unix.o:unix.c:(.text+0x62b): undefined reference to `_ttd_strlcpy'
unix.o:unix.c:(.text+0x659): undefined reference to `_str_validate'
unix.o:unix.c:(.text+0x80f): undefined reference to `_ttd_strlcpy'
unix.o:unix.c:(.text+0x8ba): undefined reference to `_ttd_strlcpy'
unix.o:unix.c:(.text+0x8db): undefined reference to `_ttd_strlcpy'
unix.o:unix.c:(.text+0x8e3): undefined reference to `_str_validate'
unix.o:unix.c:(.text+0xa68): undefined reference to `_ttd_strlcpy'
unix.o:unix.c:(.text+0xbde): undefined reference to `_ttd_strlcpy'
unix.o:unix.c:(.text+0xbfa): undefined reference to `_ttd_strlcpy'
unix.o:unix.c:(.text+0x10da): undefined reference to `_ttd_strlcpy'
unix.o:unix.c:(.text+0x1107): undefined reference to `_ttd_strlcpy'
unix.o:unix.c:(.text+0x1171): more undefined references to `_ttd_strlcpy' follow
unix.o:unix.c:(.text+0x11a4): undefined reference to `_str_fmt'
unix.o:unix.c:(.text+0x11b9): undefined reference to `_str_fmt'
unix.o:unix.c:(.text+0x11d3): undefined reference to `_str_fmt'
unix.o:unix.c:(.text+0x11ed): undefined reference to `_str_fmt'
unix.o:unix.c:(.text+0x1207): undefined reference to `_str_fmt'
unix.o:unix.c:(.text+0x122e): more undefined references to `_str_fmt' follow
music/extmidi.o:extmidi.c:(.text+0x1dc): undefined reference to `_ttd_strlcpy'
collect2: ld returned 1 exit status
make: *** [openttd] Error 1
Arno Nym@penticrack /cygdrive/i/cygwin/home/openttd
$
what happend here? i installed cygwin like the wiki say it...
with vc++ express, i have errors too. it tells me often , there is missing windows.h and winsock2.h ..hm what to do here?
Posted: 03 Jun 2006 02:28
by Ryalla
penticrack wrote:some1 compiled with cygwin? it will be compiled , till the end then make ends with a lot errors, like
what happend here? i installed cygwin like the wiki say it...
with vc++ express, i have errors too. it tells me often , there is missing windows.h and winsock2.h ..hm what to do here?
Are you compiling the lang files first? You have to use strgen to do it.
Posted: 03 Jun 2006 03:10
by gigajum
@Ryalla: This are not compiling errors, this are linking errors. So it has nothing to do with the lang files. They are only needed to generate tables.h IIRC. If this file is missing or invalid the errors were others. But this looks a bit strange IMO.
What i do not understand is why they use cygwin on a linux box, or is it not a linux box? it's your MiniIN server?
To the VC++ express problem: Does it ever tell you that problem or really sometimes. if it is really sometimes you should check what causes that if it workes sometimes and sometimes not.The normal way it should work alyways or not and not sometimes
Posted: 03 Jun 2006 07:58
by penticrack
ok vc++ express say it always, not often
i use cygwin for making a win32 exe , on my linux server make working fine without any problems.
after make clean it works... i thought touch * suffices
hm...but cygwin makes a exe, but i cant start it o_0 ...hm i want to make a exe for everone outer there...but if i start openttd.exe hdd works a bit and then program ends without errors? what have i done? a zombie?
Posted: 04 Jun 2006 09:06
by penticrack
now i changed paths and typed the full path instead of the $(installdir_sdks.h.i.t) , and now there are no more "missing headerfile" errors.
now i can compile, but i cant find a openttd.exe. if i rename openttd to it, a dosbox appears and tells me , program is too big for executing
Posted: 04 Jun 2006 12:09
by Hazelrah
penticrack wrote:
now i can compile, but i cant find a openttd.exe. if i rename openttd to it, a dosbox appears and tells me , program is too big for executing
Exactly what compiler are you using? What file did your rename to openttd.exe?
-Hazelrah
Posted: 04 Jun 2006 15:49
by gigajum
Hazelrah wrote:
Exactly what compiler are you using? What file did your rename to openttd.exe?
Cygwin under linux, he said that somewhere above.
What file he renamed he said too. He renamed a file "openttd" to "openttd.exe"
i dont know what happens if i run a linux binaryunder windows. But if a exe file is currupt it mostly says it is too big to run. Have you tried to run that file under linux?
Have you ever tried it compiling with mingw under linux, like the Wiki page shows to make cross compiling?
Posted: 04 Jun 2006 17:20
by penticrack
yes i read the wiki, but it doesnt help.
and on the other hand, i didnt made exact postings, so u must wondering
my problems with cygwin:
compilingproblems: solved (have to type "make clear" not only "touch *")
description:
cygwin is a commandline linux under windows, but usually u can compile with it and run the compiled files under windows.
problem:
if i want to execute the compiled exe it says something like its too big for running...
my problems with visual c++ 2005 express (known as vc++ 8.0):
compilingproblems:
particularly solved, compiler says: missing windows.h, png.h, zlib.h
added the whole path to sdk, and now compiling almost fine.
2 errors/warning with 32 and 64bit casts (never mind)
1fail, 1 success... and i didnt find any file named openttd.exe o_0
found a file openttd, append .exe after and it doesnt start...
i searched a while and found no openttd_vs80.sln, i upgraded the openttd.sln, "maybe this is the problem" i thought. but i couldnt find any file in my svnfolder. tortoise doesnt copy it, dont know why.
then i surfed with browser on svn.openttd.org, and found em. then i downloaded openttd_vs80.sln , and the right openttd_vs8.dsw (similar?)file , then compile tells me it need more files for opening dsw file ...
now i have to copy it manually, i didnt had time, but at evening i will try. about 4 files remain to copy...
Posted: 04 Jun 2006 21:30
by Darkvater
If you do an SVN checkout you have all the files you need, you don't need to download anything from the web(svn) since you already have that. The .dsw file is for VC6, you have absolutely no use for it.
The interesting part is the errors you get when compiling and which you should be able to find very easily in either the output window or the errors window. Don't forget the unzip the useful.zip file (headers in include/ directory, libraries in lib/ directory).