Compiling linux server under windows under Cygwin

Requests for assistance and other HOWTOs.

Moderator: Board moderators

Stwong
Luser
Posts: 19
Joined: Sat Nov 29, 2003 4:36 pm

Compiling linux server under windows under Cygwin

Post by Stwong »

note { the following posts have been massively edited by me several times to avoid 3253754 (not to scale) double posts due to progress on this issue. }

Is it possible? If so, how?

I'm absolutely no good at C, so I have no idea why it'd spit this out:
gcc wrote:gcc -g -O2 -o random_map.exe standalone.o ./common/libcross.a librandom_map.a
-lcrypt ../common/libcross.a(loader.o)(.text+0xa3b8): In function `lex_load':
/home/Administrator/crossfire/common/loader.l:635: undefined reference to `_atoll'
../common/libcross.a(loader.o)(.text+0xa3fc):/home/Administrator/crossfire/commo
n/loader.l:636: undefined reference to `_atoll'
../common/libcross.a(exp.o)(.text+0x74d): In function `init_experience':
/home/Administrator/crossfire/common/exp.c:193: undefined reference to `_atoll'
collect2: ld returned 1 exit status
make[1]: *** [random_map.exe] Error 1
make[1]: Leaving directory `/home/Administrator/crossfire/random_maps'
make: *** [all-recursive] Error 1
I'm using Win2k running Cygwin with pretty much everything installed. Downloaded CVS code, and ran configure--that went through flawlessly afaik, then ran make. It spewed that error and exited make. Any suggestions as to how to get CVS version working would be great. I just downloaded from CVS today on 12-4-2003 for reference.

I couldn't find a source package readable by windows, so I'm pretty much forced to use development versions if i want to attempt this...
Last edited by Stwong on Sat Dec 06, 2003 12:05 am, edited 1 time in total.
Ryo
Forum Fanatic
Posts: 752
Joined: Mon May 19, 2003 9:16 pm
Location: Paris, France

Re: Compiling linux server under windows under Cygwin

Post by Ryo »

Stwong wrote:/home/Administrator/crossfire/common/exp.c:193: undefined reference to `_atoll'
collect2: ld returned 1 exit status
make[1]: *** [random_map.exe] Error 1
make[1]: Leaving directory `/home/Administrator/crossfire/random_maps'
make: *** [all-recursive] Error 1

I couldn't find a source package readable by windows, so I'm pretty much forced to use development versions if i want to attempt this...
(snipped some parts)

Your missing function looks like what i had under visual studio. Check include/global.h, there should be a #define _atoll <some other function>, maybe you need it.

What do you mean by 'source package readable by windows'?
CVS tree should compile (granted, under visual studio) right out of the box.
Now the .tar.gz files in the download section will probably not compile correctly under windows, as fixes were introduced after their release.
Stwong
Luser
Posts: 19
Joined: Sat Nov 29, 2003 4:36 pm

Post by Stwong »

latest sources i saw was in rpm format and ive never seen a windows rpm reader :P

thanks for hints, ill take a look

global.h had it defined in one spot, with an #else and then it not defined within the else (?)

I cut and pasted it over, and it then borked compiling saying _atoi64 was undefined. (atoll was defined as _atoi64 earlier)

i noticed its used as a factor in exp related calculations--im checking what happens if i define it as 1

whoops, it IS a function... mai bad :P

redid global.h a bit, made an insert at line 72
/* use atoi under cygwin systems--how you figure out if it's cygwin, ionno */
#define atoll(x) _atoi(x)
apparantly _atoi is defined, but _atoi64 is not

It compiles past that landmine, then pukes with TTY under daemon.c
make wrote:daemon.c: In function `BecomeDaemon':
daemon.c:123: error: `TIOCNOTTY' undeclared (first use in this function)
daemon.c:123: error: (Each undeclared identifier is reported only once
daemon.c:123: error: for each function it appears in.)
make[1]: *** [daemon.o] Error 1
make[1]: Leaving directory `/home/Administrator/crossfire/server'
make: *** [all-recursive] Error 1
Now, at line 123 in daemon.c:
daemon.c wrote: (void) ioctl (i, TIOCNOTTY, (char *) 0); /* detach, BSD style */
Alright, so I have no idea what the TIOC or the TTY stands for, but i have an idea that I'm lacking one of them, especially due to the surrounding code:
daemon.c wrote: if ((i = open ("/dev/tty", O_RDWR)) >= 0) { /* did open succeed? */
#if (defined(SYSV) || defined(hpux)) && defined(TIOCTTY)
int zero = 0;
(void) ioctl (i, TIOCTTY, &zero);
#else

# ifdef HAVE_SYS_TERMIOS_H
# include <sys/termios.h>
# else
# ifdef HAVE_SYS_TTYCOM_H
# include <sys/ttycom.h>
# endif
# endif
(void) ioctl (i, TIOCNOTTY, (char *) 0); /* detach, BSD style */
#endif
(void) close (i);
}
Here's the funny part: Under cygwin, i lack either a /dev/ or a /sys/.
bash wrote:$ cd /

Administrator@stwong /
$ ls
bin cygwin.bat cygwin.ico etc home lib sbin tmp usr var

Administrator@stwong /
$
Hmm... since it can't read anything in /dev/ anyway if it doesnt exist, what happens if i comment that entire chunk?

commented lines 110-126 in daemon.c and it appears to be compiling longer without puking...

make finished somewhat without obviously puking. LOTS of warnings, but it has been said those should be ignored using MSVC, so ill ignore them using GCC as well :)

now, to try make install to see if it works

...

_atoi64 to _atoi was not a good idea apparantly:
crossfire.exe wrote:Reading attack messages from /usr/games/crossfire/share/crossfire/attackmess...g
ot 260 messages in 19 categories.
Reading clockdata from /usr/games/crossfire/var/crossfire/clockdata...todtick=0
Experience for level 112 is lower than previous level (2147483647 <= 2147483647)
It only chops off about 5 levels as a temp fix, but a later fix would be needed should this actually be sourced (and as a side effect, hell freezing over--would need some code to check for cygwin)

/usr/games/crossfire/etc/crossfire/etc_table
line 35
max_level 110

instead of

max_level 115

line 112-113
#3141600000, 6283200000, 12566400000,
#25132800000, 50265600000


instead of

3141600000, 6283200000, 12566400000,
25132800000, 50265600000


However, once the exp table is fixed to allow for the _atoi fix, running crossfire.exe gives this:

<hit on firewall>
crossfire.exe wrote:Waiting for connections...
doeric_server: error on select: Bad file descriptor
doeric_server: error on select
Waiting for connections...
doeric_server: error on select: Bad file descriptor
doeric_server: error on select
Waiting for connections...
doeric_server: error on select: Bad file descriptor
doeric_server: error on select
Waiting for connections...
doeric_server: error on select: Bad file descriptor
doeric_server: error on select

SIGINT received.
Emergency saves disabled, no save attempted
Cleaning up...
The waiting for connections / doeric_server things are an infinite loop apparantly, I used CTRL-C and it popped out to bash after SIGINT recieved.

Any ideas?

(As for the warnings during compile--All the ones ive been able to read were no newline at end of code warnings.

As for switching _atoi64 to _atoi, _atoi64 does not appear to be recognized by cygwin's gcc port... nor does it recognize _atoll or atoll, one of which appears to be the linux version... So looks like im in a tough spot with that.)
Ryo
Forum Fanatic
Posts: 752
Joined: Mon May 19, 2003 9:16 pm
Location: Paris, France

Post by Ryo »

For the atoll / _atoi64 issue, i don't know enough Cygwin to help you there. MSVC has the _atoi64 function, that's why you saw the #define atoll _atoi64.

But since Cygwin is a port of unix things, hopefully you do have somewhere the atoll function, or some equivalent....

Note that the #ifdef WIN32 are intented for MSVC. Maybe that could be fixed to use another macro name.

For server sources, try that: http://sourceforge.net/project/showfile ... _id=142714
That's a .tar.gz file, should be easy to open.
Note: those sources are old, february...

You'd be better with the latest CVS ones, i guess.
Check http://sourceforge.net/cvs/?group_id=13833 for instructions, the module name you want is 'crossfire' (though you may also want 'arch' if you plan on modifying the archetypes)

CVS warning: if you use command-line, USE the --nl flag. For other interfaces, make TRIPLE sure the 'use unix-like newline' or some equivalent option is SET. You WANT Unix-like newlines, else the server will simply NOT run at ALL.
(this applies to ALL CVS updates)
Stwong
Luser
Posts: 19
Joined: Sat Nov 29, 2003 4:36 pm

Post by Stwong »

I use syn/vi to edit all my source, and I've seen syn saying it's saving it as unix nl's... but I'll take a look at that and double check again. (Cygwin is set to unix style newlines already by default)

Cygwin has atol but not atoll . Haha.
ANSI-compliant functions under cygwin gcc wrote:<clip>, atof, atoi, atol, </clip>
grep wrote:$ grep -b -R "[\b]*doeric[\b]*" "./"
./include/sockproto.h:2234:void doeric_server(void);
./server/main.c:38443: doeric_server();
./server/player.c:63776: * the players time has been increased when doericse
rver has been
Binary file ./server/main.o matches
Binary file ./server/crossfire.exe matches
./socket/loop.c:13644:void doeric_server()
./socket/loop.c:15438: perror("doeric_server: error on select");
./socket/loop.c:15481: LOG(llevError,"doeric_server: error on select\n");
./socket/loop.c:15786: LOG(llevDebug,"doeric_server: New Connection\n");
./socket/loop.c:16522: perror("doeric_server: error on accept");
./socket/loop.c:16569: LOG(llevError,"doeric_server: error on accept\n");
Binary file ./socket/loop.o matches
Binary file ./socket/libsocket.a matches
./socket/loop.c lines 526-527 wrote: pollret= select(socket_info.max_filedescriptor, &tmp_read, &tmp_write,
&tmp_exceptions, &socket_info.timeout);
To me it seems like it polling the sockets here... which are defined at the top of loop.c:
./socket/loop.c lines 42-48 wrote:#ifndef WIN32 /* ---win32 exclude unix headers */
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#endif /* end win32 */
Of course, here's the dev/sys issue again... Of course, if I forcefully define WIN32 at the top of every file, it'll be one sloppy fix, and it probably wont fix it because the MSVC specific defines are around as well... I'm going to look into seeing what select does...
tapiola + me wrote:<Tapiola> good old gcc-2.95 is the most stable so far :-)
<Stwong> :P
<Tapiola> although 3.2 might work too
<Stwong> I'll try 3.2
<Tapiola> i only tried 3.3 and 2.95
GCC 3-2-3 does not work either, and those are the only two available for Cygwin. I'll just try to use MinGW.
User avatar
hoxu
Senior member
Posts: 330
Joined: Tue Apr 29, 2003 6:10 am

Post by hoxu »

I think I asked this in irc already but

what's the point of trying to compile the server in cygwin when it's supposed to compile natively on windows?

I think it would be very nice if people were able to compile the server on windows using a free compiler. :roll:

/* Debian GNU/Linux - rebooting is for adding hardware. */
Stwong
Luser
Posts: 19
Joined: Sat Nov 29, 2003 4:36 pm

Post by Stwong »

Problem with minGW is it spews more errors than Cygwin. Sorry. I'll just switch to MSVC and sit this one out... Anyone else interested in trying to make it work under MinGW?
User avatar
hoxu
Senior member
Posts: 330
Joined: Tue Apr 29, 2003 6:10 am

Post by hoxu »

I would be if I had a Wintendo box. Perhaps you could tell us more about those errors and we could see if anything can be done? :)

/* Debian GNU/Linux - rebooting is for adding hardware. */
Stwong
Luser
Posts: 19
Joined: Sat Nov 29, 2003 4:36 pm

Post by Stwong »

It just stops at the first fatal one, and that's one of the typecasting ones ryo is trying to fix--as in, merely a warning in MSVC
Ryo
Forum Fanatic
Posts: 752
Joined: Mon May 19, 2003 9:16 pm
Location: Paris, France

Post by Ryo »

Aren't you using a flag like -W which, iirc, makes warnings behave like errors and stop the build process?
The warnings you can ignore, hopefully.
Post Reply