Author Topic: Compiling simutrans under linux, using gcc with codeblocks  (Read 2500 times)

0 Members and 1 Guest are viewing this topic.

Offline eldorico

Compiling simutrans under linux, using gcc with codeblocks
« on: July 15, 2013, 03:35:51 PM »


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:

Quote
Libraries needed:


libz http://www.zlib.net/(external link)
bzip2 http://www.bzip.org/(external link)
libpng http://www.libpng.org/pub/png/(external link) for makeobj
libSDL and libSDL_mixer http://www.libsdl.org/(external link) for SDL
Allegro http://www.talula.demon.co.uk/allegro/(external link) (or http://alleg.sourceforge.net/index.de.html)(external 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):

Quote

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


Eldorico



Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4870
  • Total likes: 202
  • Helpful: 108
  • Languages: EN, NO
Re: Compiling simutrans under linux, using gcc with codeblocks
« Reply #1 on: July 15, 2013, 03:51:43 PM »
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).

Offline eldorico

Re: Compiling simutrans under linux, using gcc with codeblocks
« Reply #2 on: July 16, 2013, 01:23:25 PM »
Thanks for help  :)


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


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



Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4870
  • Total likes: 202
  • Helpful: 108
  • Languages: EN, NO
Re: Compiling simutrans under linux, using gcc with codeblocks
« Reply #3 on: July 16, 2013, 02:29:25 PM »
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 simsys_x8.cc, 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.

Offline eldorico

Re: Compiling simutrans under linux, using gcc with codeblocks
« Reply #4 on: July 17, 2013, 02:29:08 PM »
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 loadsave.cc (and many more).


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


Quote
/dataobj/loadsave.cc:183: undefined reference to `BZ2_bzReadOpen'

EDIT: It is a problem x64  :-[ 
Quote
EDIT: 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  ;)


« Last Edit: July 17, 2013, 03:24:59 PM by eldorico »

Offline kierongreen

Re: Compiling simutrans under linux, using gcc with codeblocks
« Reply #5 on: July 17, 2013, 02:49:42 PM »
You'll need libbz2 as well as libz