[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

Compiling a c program

Robert Hinson

5/4/2011 5:10:00 AM

I am trying to compile an old copy of the fics chess server.

It gives undefined refence errors. Can someone help me with this so I
can compile it and make it work?

[oppie@fedora fics.1.7.4]$ make
gcc ficsmain.o -DLINUX -g network.o utils.o lists.o formula.o
playerdb.o talkproc.o command.o comproc.o matchproc.o movecheck.o
ratings.o gamedb.o rmalloc.o vers.o variable.o board.o gameproc.o
algcheck.o adminproc.o multicol.o eco.o rating_conv.o shutdown.o
obsproc.o setup.o pending.o -lm -lcrypt -o fics
ficsmain.o: In function `main':
/home/oppie/FreeChess/FICS/fics.1.7.4/ficsmain.c:188: undefined
reference to `init_userstat'
command.o: In function `process_heartbeat':
/home/oppie/FreeChess/FICS/fics.1.7.4/command.c:1063: undefined
reference to `userstat'
/home/oppie/FreeChess/FICS/fics.1.7.4/command.c:1064: undefined
reference to `save_userstat'
/home/oppie/FreeChess/FICS/fics.1.7.4/command.c:1067: undefined
reference to `userstat'
/home/oppie/FreeChess/FICS/fics.1.7.4/command.c:1068: undefined
reference to `save_userstat'
/home/oppie/FreeChess/FICS/fics.1.7.4/command.c:1070: undefined
reference to `userstat'
/home/oppie/FreeChess/FICS/fics.1.7.4/command.c:1071: undefined
reference to `userstat'
/home/oppie/FreeChess/FICS/fics.1.7.4/command.c:1072: undefined
reference to `userstat'
/home/oppie/FreeChess/FICS/fics.1.7.4/command.c:1073: undefined
reference to `save_userstat'
/home/oppie/FreeChess/FICS/fics.1.7.4/command.c:1075: undefined
reference to `userstat'
/home/oppie/FreeChess/FICS/fics.1.7.4/command.c:1076: undefined
reference to `userstat'
/home/oppie/FreeChess/FICS/fics.1.7.4/command.c:1077: undefined
reference to `userstat'
/home/oppie/FreeChess/FICS/fics.1.7.4/command.c:1078: undefined
reference to `save_userstat'
command.o: In function `TerminateCleanup':
/home/oppie/FreeChess/FICS/fics.1.7.4/command.c:1122: undefined
reference to `save_userstat'
command.o:(.data+0x788): undefined reference to `com_ustat'
command.o:(.data+0x798): undefined reference to `com_pstat'
matchproc.o: In function `create_new_match':
/home/oppie/FreeChess/FICS/fics.1.7.4/matchproc.c:279: undefined
reference to `userstat'
/home/oppie/FreeChess/FICS/fics.1.7.4/matchproc.c:279: undefined
reference to `userstat'
gamedb.o: In function `game_write_complete':
/home/oppie/FreeChess/FICS/fics.1.7.4/gamedb.c:1799: undefined reference
to `game_save_playerratio'
/home/oppie/FreeChess/FICS/fics.1.7.4/gamedb.c:1808: undefined reference
to `game_save_playerratio'
collect2: ld returned 1 exit status
make: *** [fics] Error 1
[oppie@fedora fics.1.7.4]$

Here is ficsmain.c:

[oppie@fedora fics.1.7.4]$ cat ficsmain.c
/* ficsmain.c
*
*/

/*
fics - An internet chess server.
Copyright (C) 1993 Richard V. Nash

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/

/* Revision history:
name email yy/mm/dd Change
Richard Nash 93/10/22 Created
*/

#include "stdinclude.h"

#include "common.h"
#include "ficsmain.h"
#include "config.h"
#include "network.h"
#include "command.h"
#include "playerdb.h"
#include "ratings.h"
#include "utils.h"
/*#include "hostinfo.h" */
#include "board.h"
#include "talkproc.h"
#include "comproc.h"
#include "shutdown.h"
#ifndef IGNORE_ECO
#include "eco.h"
#endif
#include <sys/param.h>

/* Arguments */
PUBLIC int port;
/* PUBLIC int withConsole; */

PRIVATE void usage(char *progname)
{
fprintf(stderr, "Usage: %s [-p port] [-C] [-h]\n", progname);
fprintf(stderr, "\t\t-p port\t\tSpecify port.
(Default=%d)\n",DEFAULT_PORT);
fprintf(stderr, "\t\t-C\t\tStart with console player connected to
stdin.\n");
fprintf(stderr, "\t\t-h\t\tDisplay this information.\n");
exit(1);
}

PRIVATE void GetArgs(int argc, char *argv[])
{
int i;

port = DEFAULT_PORT;
/* withConsole = 0; */

for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'p':
if (i == argc - 1)
usage(argv[0]);
i++;
if (sscanf(argv[i], "%d", &port) != 1)
usage(argv[0]);
break;
/*
case 'C':
withConsole = 1;
break;
*/
case 'h':
usage(argv[0]);
break;
}
} else {
usage(argv[0]);
}
}
}

PRIVATE void main_event_loop(void) {

int current_socket;
char command_string[MAX_STRING_LENGTH];

while (1) {
ngc2(command_string, HEARTBEATTIME);
if (process_heartbeat(&current_socket) == COM_LOGOUT) {
process_disconnection(current_socket);
net_close_connection(current_socket);
}
}
}

void TerminateServer(int sig)
{
fprintf(stderr, "FICS: Got signal %d\n", sig);
output_shut_mess();
TerminateCleanup();
net_close();
#if 0
if (allocated_size > 0)
fprintf(stderr, "Memory leak discovered while shutting down.\n");
#endif
exit(1);
}

void BrokenPipe(int sig)
{
signal(SIGPIPE, BrokenPipe);
fprintf(stderr, "FICS: Got Broken Pipe\n");
}

PUBLIC int main(int argc, char *argv[])
{

#ifdef DEBUG
#ifdef HAVE_MALLOC_DEBUG
malloc_debug(16);
#endif
#endif
GetArgs(argc, argv);
signal(SIGTERM, TerminateServer);
signal(SIGINT, TerminateServer);
signal(SIGPIPE, BrokenPipe);
if (net_init(port)) {
fprintf(stderr, "FICS: Network initialize failed on port %d.\n",
port);
exit(1);
}
startuptime = time(0);

/* Using the value defined in config.h now instead of the real
* hostname.
This is used as the return address in email, so it needs to be a
real
DNS resolvable hostname! Sparky
*/
/* gethostname(fics_hostname, 80); */

strcpy ( fics_hostname, SERVER_HOSTNAME );
quota_time = 60;
player_high = 0;
game_high = 0;
srand(startuptime);
fprintf(stderr, "FICS: Initialized on port %d at %s.\n", port,
strltime(&startuptime));

#if 0
iamserver = 0;
if (hostinfo_init()) {
MailGameResult = 0;
fprintf(stderr, "FICS: No ratings server connection.\n");
} else {
if (iamserver) {
fprintf(stderr, "FICS: I don't know how to be a ratings server,
refusing.\n");
MailGameResult = 0;
} else {
fprintf(stderr, "FICS: Ratings server set to: %s\n",
hArray[0].email_address);
MailGameResult = 1;
}
}
if (mail_log_file)
fclose(mail_log_file);
#endif

#ifdef FOPEN_CLUDGE
file_init(30);
#endif

fprintf(stderr, "FICS: commands_init()\n");
commands_init();
/* fprintf(stderr, "FICS: channel_init()\n");
channel_init(); */
fprintf(stderr, "FICS: rating_init()\n");
rating_init();
fprintf(stderr, "FICS: wild_init()\n");
wild_init();
#ifndef IGNORE_ECO
fprintf(stderr, "FICS: book init()\n");
BookInit();
#endif
fprintf(stderr, "FICS: userstat_init()\n");
init_userstat();

fprintf(stderr, "FICS: player_array_init()\n");
player_array_init();
/* player_init(withConsole); */ /* Start the super-user as console if
-C spec */
main_event_loop();
/* will never get here - uses TerminateServer */

return 0;
}
[oppie@fedora fics.1.7.4]$



--
--
Insert coin for new game
6 Answers

gordonb.a7kg8

5/4/2011 6:12:00 AM

0

> I am trying to compile an old copy of the fics chess server.
>
> It gives undefined refence errors. Can someone help me with this so I

You can't refence what hasn't been fenced in the first place.
Speling counts.

> can compile it and make it work?
>
> [oppie@fedora fics.1.7.4]$ make
> gcc ficsmain.o -DLINUX -g network.o utils.o lists.o formula.o
> playerdb.o talkproc.o command.o comproc.o matchproc.o movecheck.o
> ratings.o gamedb.o rmalloc.o vers.o variable.o board.o gameproc.o
> algcheck.o adminproc.o multicol.o eco.o rating_conv.o shutdown.o
> obsproc.o setup.o pending.o -lm -lcrypt -o fics

You are missing definitions of:
init_userstat
userstat
save_userstat
com_ustat
com_pstat
game_save_playerratio

Are you sure the command above doesn't leave out any files? (like
userstat.o?) or libraries? -lm and -lcrypt are two libraries that
are unlikely to contain definitions from the list above.

Perhaps there's a preprocessor define you are supposed to set to
avoid (or include) the pieces associated with user stats? Use grep
to find all the places in the files that refer to 'userstat' and
see if there are parts #if'd out.

The reference to init_userstat in ficsmain.c doesn't seem to be
inside a preprocessor conditional.

Robert Hinson

5/4/2011 7:57:00 AM

0

Ok, I fixed that. Now I have another problem.

gcc -DLINUX -g -c -o gics.o gics.c
gics.c:193:7: error: conflicting types for â??dprintfâ??
/usr/include/stdio.h:419:12: note: previous declaration of â??dprintfâ?? was
here
make: *** [gics.o] Error 1

This is gics.c:
PUBLIC void dprintf(char *format,...)
{
char tmp[10 * MAX_LINE_SIZE]; /* Make sure you can handle 10 lines
worth of
* stuff */
int retval;
time_t now;
va_list ap;

va_start(ap, format);

retval = vsprintf(tmp, format, ap);
if (strlen(tmp) > 10 * MAX_LINE_SIZE) {
return;
}
time(&now);
if (tmp[strlen(tmp) - 1] != '\n') {
fprintf(stderr, "%s %s\n", strltime(&now), tmp);
} else {
fprintf(stderr, "%s %s", strltime(&now), tmp);
}
va_end(ap);
return;
}

This is /usr/include.stdio.h:
#ifdef __USE_XOPEN2K8
/* Write formatted output to a file descriptor.

These functions are not part of POSIX and therefore no official
cancellation point. But due to similarity with an POSIX interface
or due to the implementation they are cancellation points and
therefore not marked with __THROW. */
extern int vdprintf (int __fd, __const char *__restrict __fmt,
_G_va_list __arg)
__attribute__ ((__format__ (__printf__, 2, 0)));
extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
#endif

On 2011-05-04, Gordon Burditt <gordonb.a7kg8@burditt.org> wrote:
>> I am trying to compile an old copy of the fics chess server.
>>
>> It gives undefined refence errors. Can someone help me with this so I
>
> You can't refence what hasn't been fenced in the first place.
> Speling counts.
>
>> can compile it and make it work?
>>
>> [oppie@fedora fics.1.7.4]$ make
>> gcc ficsmain.o -DLINUX -g network.o utils.o lists.o formula.o
>> playerdb.o talkproc.o command.o comproc.o matchproc.o movecheck.o
>> ratings.o gamedb.o rmalloc.o vers.o variable.o board.o gameproc.o
>> algcheck.o adminproc.o multicol.o eco.o rating_conv.o shutdown.o
>> obsproc.o setup.o pending.o -lm -lcrypt -o fics
>
> You are missing definitions of:
> init_userstat
> userstat
> save_userstat
> com_ustat
> com_pstat
> game_save_playerratio
>
> Are you sure the command above doesn't leave out any files? (like
> userstat.o?) or libraries? -lm and -lcrypt are two libraries that
> are unlikely to contain definitions from the list above.
>
> Perhaps there's a preprocessor define you are supposed to set to
> avoid (or include) the pieces associated with user stats? Use grep
> to find all the places in the files that refer to 'userstat' and
> see if there are parts #if'd out.
>
> The reference to init_userstat in ficsmain.c doesn't seem to be
> inside a preprocessor conditional.
>


--
--
Insert coin for new game

phrogg

5/4/2011 8:33:00 AM

0

On Wed, 04 May 2011 01:12:11 -0500, gordonb.a7kg8@burditt.org (Gordon
Burditt) wrote:

>You can't refence what hasn't been fenced in the first place.
>Speling counts.

I do not make comments about miss spelling (I am very guilty of miss
spelling) because that is a personal attack, but I find it amusing
that you miss spelled "Speling". :-)


James Kuyper

5/4/2011 10:13:00 AM

0

On 05/04/2011 04:33 AM, Mickey Mouse wrote:
> On Wed, 04 May 2011 01:12:11 -0500, gordonb.a7kg8@burditt.org (Gordon
> Burditt) wrote:
>
>> You can't refence what hasn't been fenced in the first place.
>> Speling counts.
>
> I do not make comments about miss spelling (I am very guilty of miss
> spelling) because that is a personal attack, ...

You should not take spelling corrections personally; you are not your
spelling; to criticize one is not to attack the other.

> ... but I find it amusing
> that you miss spelled "Speling". :-)

Complaints about spelling mistakes are supposed to contain spelling
mistakes. People will insert mistakes deliberately, if necessary, to
maintain the tradition.
--
James Kuyper

Mark Bluemel

5/4/2011 10:35:00 AM

0

On 05/04/2011 11:13 AM, James Kuyper wrote:
> On 05/04/2011 04:33 AM, Mickey Mouse wrote:
>> On Wed, 04 May 2011 01:12:11 -0500, gordonb.a7kg8@burditt.org (Gordon
>> Burditt) wrote:
>>
>>> You can't refence what hasn't been fenced in the first place.
>>> Speling counts.
>>
>> I do not make comments about miss spelling (I am very guilty of miss
>> spelling) because that is a personal attack, ...
>
> You should not take spelling corrections personally; you are not your
> spelling; to criticize one is not to attack the other.
>
>> ... but I find it amusing
>> that you miss spelled "Speling". :-)
>
> Complaints about spelling mistakes are supposed to contain spelling
> mistakes. People will insert mistakes deliberately, if necessary, to
> maintain the tradition.

http://en.wikipedia.org/wiki/Muph...

Ben Bacarisse

5/4/2011 10:49:00 AM

0

Robert Hinson <oppie@linuxassistant.com> writes:

> Ok, I fixed that. Now I have another problem.
>
> gcc -DLINUX -g -c -o gics.o gics.c
> gics.c:193:7: error: conflicting types for â??dprintfâ??
> /usr/include/stdio.h:419:12: note: previous declaration of â??dprintfâ?? was
> here
> make: *** [gics.o] Error 1

Unadorned gcc will turn on all sorts of features than cause otherwise
standard headers (like stdio.h) to declare many traditional functions.
dprintf is one such function.

You may be better off telling gcc be a standard C compiler and turning
on features as you discover that you need them. Add -ansi -pedantic to
the gcc command and see how that goes.

<snip>
--
Ben.