Make Simutrans speak your language.

Compiling simutrans under linux, using gcc with codeblocks

Started by eldorico, July 15, 2013, 03:35:51 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Hi every one!

First, I'm afraid this topic may be posted in a codeblocks, ubuntu or gcc forum, but since it's my first try at compiling a complete source code with codeblocks, i try to post here. If the post should go in another forum, please tell me ^^

I want to compile the trunk source with codeblocks under Linux.
I've read the "compile with Linux documentation", and I've installed the dev libraries for compiling it:

Libraries needed:

libz link)
bzip2 link)
libpng link) for makeobj
libSDL and libSDL_mixer link) for SDL
Allegro link) (or link) for Allegro

Note: on Debian/Ubuntu -dev versions of libraries has to be installed separately.

For all other systems, it is recommended you get the latest GCC and
matching zlib, and libpng and a game library. For unix system you may
have to use tools like apt-get or yast.

It is recommended that you always use the latest source version.

So I tried to compile the trunk folder, building from simmain.h, and using gcc under codeblocks. But I've got many errors, and I think its because I haven't done this part (because I don't know how to manage it):

Compiling with GCC

Go to Simutrans/sim.

Then copy the file sim/config.template to sim/config.default and edit the
file. You need to specify:
- frontend (gdi, allegro, sdl)
- color depth (usually 16)
- system (you should know it)

I recommend to uncomment #DEBUG=1 and #OPTIMISE = 1 (i.e. removing the #).

For allegro or libsdl you may need to define the path of the config file
(or at least on Win98 and empty path).

Finally type make. If you want a smaller program and do not care about error
messages, you can comment out #DEBUG=1 and run strip sim resp. strip sim.exe
after compile and linking.

I read, "copy the config.template to sim/config.default and edit the file":
-->Should I create a "sim" folder? Where?
-->Or should I simply copy the config.template in the trunk/simutrans folder? (and specify my system, color depth etc.? 

Thanks for your help  ;D



config.default isn't used when building with codeblocks, only when using make. However, you must #define some of the same parameters that config.default would otherwise define for you. COLOR_DEPTH is the only one really needed, and should be set to 16 for anything but a headless server. At some point, you might also need to define DEBUG.

When setting up a codeblocks build, do not include all files in the build. You only need one of the simgraphs and one of the simsyses. The files in besch/writer belongs to makeobj only (I have never set up this in codeblocks). I think there are some files in util that also should be excluded, but it's been a while since I last set everything up from scratch.

Getting Simutrans to run from within codeblocks is also a bit tricky, as Simutrans needs a lot of files that are not part of the build (translations and pak sets).


Thanks for help  :)

Can I #define COLOR_DEPTH 16 directly in and #define DEBUG here to?

I also tried building only with the which I think it uses the X11 server, but I've got many "non declared" errors. Should I " #define OSTYPE linux " some where?


I put the #defines in codeblock's build properties dialog. They need to be passed to a lot of files, so putting them in any one file might not work, and certainly not a .cc file.

And if you still have, you must have some really old source code. It was deleted a long time ago.

You also seem unfamilar with C++ development. The combination of Simutrans and Codeblocks isn't exactly friendly to beginners. It's not very friendly to me, and I've got about 15 years of C++ experience.


Hahaha! I didn't notice that I had an old source code thanks ^^
Yes, I'm a beginner but I love learn things doing this manner. :-)
With all the includes and removing all the libraries I don't need, it compiles fine, thank you for your help.

I'm working know against linker options and libraries.  :-[
The program can't link the zlib libraries used for (and many more).

I linked the zlib.a in the build-options, but still I can't load the BZ2_bzReadOpen() used in
Did I miss something? Is it because I have a 64-linux OS? (I take the static library in a 32b folder)

Quote/dataobj/ undefined reference to `BZ2_bzReadOpen'

EDIT: It is a problem x64  :-[ 
QuoteEDIT: i386:x86-64 architecture of input file `obj/Debug/aburch-simutrans-71a395c/bauer/brueckenbauer.o' is incompatible with i386 output

EDIT: Should I create a new post?
EDIT: I'll try in codeblocks forums ^^ Thanks for help  ;)