News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

The Compile Sequence

Started by Ormac, September 14, 2008, 12:47:58 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ormac

Recently I have started looking at the source code for simutrans.

I seem capable of handing svn and at least updating my working copy with svn up.
so far I have been only been tinkering around the edges of the in-game help files. I now would like to build simutrans from my local copy of the source code to test my changes.

I've read this particular thread from http://archive.forum.simutrans.com/topic/08052.0/index.html.

When I run make from simutrans/trunk as the  thread suggests

I get errors like

dataobj/loadsave.cc:498: error: 'gzprintf' was not declared in this scope
dataobj/loadsave.cc:498: warning: unused variable 'gzprintf'
dataobj/loadsave.cc: In member funtion 'void loadsave_t::rd_obj_id(char*, int)'


I think this means I need to include the source code for zlib. and libpng as outlined by the readme.txt that came with the simutrans sourcecode.

I now have the source code for zlib and libpng libraries. I just don't know where I put this source code or if there is a specific compile sequence now to build simutrans from source.

I am trying to compile on windows using MinGW with MSYS.

Ormac 8)
Simutrans Reference Material Blog SRM very wet ink
Download Simutrans Reference Material from http://docs.simutrans.com

whoami

You don't need the source for the libraries. You can either copy the header files (*.h) into /usr/include and the libraries (*.lib) to /usr/lib, or keep the library separate and use additional -I and -L options to inform compiler and linker of that location.

Ormac

Alright I copied all the header files (*.h) over to the MinGW include folder. I couldn't find any *.lib files though.

Ran make again. It got through to compiling object files (*.o) but then comes up against another error


c:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lz
collect2: ld returned 1 exit status
make: *** [sim] Error 1


ld.exe is in the directory indicated at the end of the search path though so I'm wondering what I have overlooked.

Ormac 8)
Simutrans Reference Material Blog SRM very wet ink
Download Simutrans Reference Material from http://docs.simutrans.com

whoami

You need this archive. it includes the .lib files. (With only the source, you can create them yourself, but that's not necessary for ST).

Ormac

Thanks for that

I've just copied the header files (*.h) to c:\MinGW\include and the (*.lib) which has been renamed to libzdll.a following the directions of USAGE.TXT which came in zlib123-dll.zip. I placed libzdll.a in c:\MinGW\lib

went through make

and again came up against


c:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lz
collect2: ld returned 1 exit status
make: *** [sim] Error 1


step 4 from USAGE.TXT says

4. Add "libzdll.a" to your project, or use the -lzdll option.

All I've put in at the command line \simutrans\trunk is make

I'm not quite sure how to add the library file to the project or exactly what options I need to specify after make.  ???

Ormac 8)
Simutrans Reference Material Blog SRM very wet ink
Download Simutrans Reference Material from http://docs.simutrans.com

isidoro

A header file (.h) contains information about the prototype of functions.  They are used by the compiler.  Their default location is /usr/include.  If you want your compiler to look somewhere else, use -I(capital i) flag.

A library file contains the actual binary code of those functions.  They are used by the linker (ld).  You have to directly include the library in the  command or use the -l(small el) flag for all libraries your project needs.  That flag is a little weird, though.  If you put -lfoo, the linker will look for a file named libfoo.something.  The default location for such files can be /usr/lib.  If your file is outside that location, you can tell the linker where to look with the -L flag.

If the linker tells you that cannot find -lz, it is because it cannot find a file named libz.something in the standard library paths.  If the replacement for such libz is libzdll.a, you have either to include that file in the command compilation line or add libzdll.a to a standard library files directory and use -lzdll instead.

Usually, all the process (compiling+linking) can be done with only one invocation to the compiler (gcc or other).  Hope it helps.

prissi

There are two libz.a, one static and the dll. YOu must use the static one, or you need the dll. The easiest way to get it, is via OpenTTD wiki ...

But I wrote the readme more from an "expert" view. If this readme can improved, that would be great.

Ormac

Thanks for the help so far

I've included the static library of libz
I'm making more sense of the compiler search paths and the libraries  but I haven't yet got it to compile successfully yet. (I think I'm getting closer though)  :)


It's stopping on a different error but suggest libz is faulty?

c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/libz.a(./zlibstat/gzio.obj):\zlib-1.2.3\gzio.c:(.text[_get_byte]+0x14): undefined reference to `errno'
c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/libz.a(./zlibstat/gzio.obj):\zlib-1.2.3\gzio.c:(.text[_check_header]+0x1a): undefined reference to `errno'
c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/libz.a(./zlibstat/gzio.obj):\zlib-1.2.3\gzio.c:(.text[_destroy]+0x56): undefined reference to `errno'
c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/libz.a(./zlibstat/gzio.obj):\zlib-1.2.3\gzio.c:(.text[_gzprintf]+0x6): undefined reference to `_chkstk'
c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/libz.a(./zlibstat/gzio.obj):\zlib-1.2.3\gzio.c:(.text[_gzerror@8]+0x3a): undefined reference to `errno'
c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/libz.a(./zlibstat/gzio.obj):\zlib-1.2.3\gzio.c:(.text[_gz_open]+0x1ba): undefined reference to `errno'
c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/libz.a(./zlibstat/gzio.obj):\zlib-1.2.3\gzio.c:(.text[_gzread@12]+0xbb): undefined reference to `errno'
collect2: ld returned 1 exit status
make: *** [sim] Error 1


I could be wrong though.

Ormac 8)

Simutrans Reference Material Blog SRM very wet ink
Download Simutrans Reference Material from http://docs.simutrans.com

wernieman

I don´t know to compile simutrans on windows but ...

Do you put the libz.a in the right Direktory?
I hope you understand my English

isidoro

Quote from: Ormac on September 18, 2008, 03:14:28 AM
It's stopping on a different error but suggest libz is faulty?

I don't think so.  The errors tell that the linker cannot find "errno".  That is a symbol located in another library libc.  That library is linked to the executable without needing to add -lc.  Is your compiler properly installed?  Have you tried to compile an easy test program with it?


Ormac

No I haven't checked if the compiler is at fault.

I will test it and get back

Ormac 8)
Simutrans Reference Material Blog SRM very wet ink
Download Simutrans Reference Material from http://docs.simutrans.com