Cannot compile GiuChess

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Roland Chastain
Posts: 685
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Cannot compile GiuChess

Post by Roland Chastain »

Hello!

I would like to fix the issue described here, and I believe I already know how to fix it, but unfortunately I can no longer compile GiuChess. I remember I could compile it some time ago. I have no idea why I cannot now. Maybe I use a different version of gcc? :?

I use the code source from here (or here).

I get many error messages about "multiple definitions".

Code: Select all

rw_thread.c: In function 'wait_for_input':
rw_thread.c:236:3: warning: implicit declaration of function 'xlog'; did you mean 'llog'? [-Wimplicit-function-declaration]
  236 |   xlog("%s\n", buf);
      |   ^~~~
      |   llog
/usr/bin/ld: exec_mov.o:(.bss+0x0): multiple definition of `last_moved_color'; check.o:(.bss+0x0): first defined here
/usr/bin/ld: exec_mov.o:(.bss+0x20): multiple definition of `w'; check.o:(.bss+0x20): first defined here
/usr/bin/ld: exec_mov.o:(.bss+0x2a0): multiple definition of `b'; check.o:(.bss+0x2a0): first defined here
/usr/bin/ld: exec_mov.o:(.bss+0x520): multiple definition of `brow'; check.o:(.bss+0x520): first defined here
/usr/bin/ld: exec_mov.o:(.bss+0x560): multiple definition of `bcol'; check.o:(.bss+0x560): first defined here
...
(I applied to the Makefile the modification described here, but it doesn't solve this problem.)

Could someone help?

Regards.

Roland
Qui trop embrasse mal étreint.

Author of Eschecs, a simple UCI chess GUI written in Pascal.
mar
Posts: 2666
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Cannot compile GiuChess

Post by mar »

you can add a prototype in rw_thread.c, say after the #include:

Code: Select all

void xlog(char *fmt, ...);
and that should do the trick
mar
Posts: 2666
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Cannot compile GiuChess

Post by mar »

also, in the makefile, I've noticed that -O4 and -Wall are only passed when linking, not compiling, so I'd suggest to change the Makefile like this:

Code: Select all

%.o:	%.c $(HEADERS)
	$(CC) -c $(COMPIL_FLAGS) $<
then it also spits some extra warnings as well (and actually optimizes the code as was originally intended)
User avatar
Roland Chastain
Posts: 685
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Cannot compile GiuChess

Post by Roland Chastain »

mar wrote: Sat Jan 15, 2022 9:08 am you can add a prototype in rw_thread.c, say after the #include:

Code: Select all

void xlog(char *fmt, ...);
and that should do the trick
Thanks Martin. Correction done. But I still get the "multiple definitions" errors. :?
mar wrote: Sat Jan 15, 2022 9:19 am also, in the makefile, I've noticed that -O4 and -Wall are only passed when linking, not compiling, so I'd suggest to change the Makefile like this:

Code: Select all

%.o:	%.c $(HEADERS)
	$(CC) -c $(COMPIL_FLAGS) $<
then it also spits some extra warnings as well (and actually optimizes the code as was originally intended)
OK, done.
Qui trop embrasse mal étreint.

Author of Eschecs, a simple UCI chess GUI written in Pascal.
mar
Posts: 2666
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Cannot compile GiuChess

Post by mar »

I don't know, it links fine here, I'm using mingw/gcc 8.1.0, perhaps you're using a different version? newer/older?

if the problem is just the "last_moved_color" variable, then that can be removed from both main.h and exec_mov.c, because it's never used anywhere
mar
Posts: 2666
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Cannot compile GiuChess

Post by mar »

ok, the problem seems to be related to the fact, that the engine uses definitions in header files and my gcc version seems to merge those globals internally.
a proper solution would be to use extern in the header files and copy the definitions into c files instead,

like in main.h, for example:

Code: Select all

piece w[16], b[16];   //w et b sont des piece*
BITMASK brow[8], bcol[8], matrix[8][8];
int arr_row[64], arr_col[64];
BITMASK array[64];
int DEBUGG;
int depthmax;
=> so you can copy this and put it in main.c and add extern prefix to those globals in the header, you may have to do this for multiple files
User avatar
Roland Chastain
Posts: 685
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Cannot compile GiuChess

Post by Roland Chastain »

Great! It works. Thank you Martin. 8-)
Qui trop embrasse mal étreint.

Author of Eschecs, a simple UCI chess GUI written in Pascal.
User avatar
Roland Chastain
Posts: 685
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Cannot compile GiuChess

Post by Roland Chastain »

GiuChess 1.0 revision 01 is available. Source only for now.
Qui trop embrasse mal étreint.

Author of Eschecs, a simple UCI chess GUI written in Pascal.
Guenther
Posts: 4718
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: Cannot compile GiuChess

Post by Guenther »

Roland Chastain wrote: Sat Jan 15, 2022 11:47 am GiuChess 1.0 revision 01 is available. Source only for now.
Would you mind to change the internal name in rw_thread.c now too for differentiating?
BTW did you test if your change works now correctly already?

I compiled it just recently and did that change for my binary. (There were dozens of warnings about unused variables)
BTW what does optimizing level 4? Never used it before.

It seems to work from cmd (played a few blind moves against it):

Code: Select all

xboard

protover 2
Chess
feature setboard=1 sigint=0 variants="normal" draw=1 reuse=1 myname="GiuChess-1.0.1 RC" done=1
new
time 3000
go
move f2f4
c7c5
move e2e4
b8c6
move d1h5
g8f6
move h5c5
e7e6
move c5e3
https://rwbc-chess.de

[Trolls n'existent pas...]
User avatar
Roland Chastain
Posts: 685
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: Cannot compile GiuChess

Post by Roland Chastain »

Guenther wrote: Sat Jan 15, 2022 1:48 pm Would you mind to change the internal name in rw_thread.c now too for differentiating?
OK, I will do it.
Guenther wrote: Sat Jan 15, 2022 1:48 pm BTW did you test if your change works now correctly already?
Yes, I run a little tournament with cutechess-cli.
Guenther wrote: Sat Jan 15, 2022 1:48 pm (There were dozens of warnings about unused variables)
Indeed, I saw that.
Guenther wrote: Sat Jan 15, 2022 1:48 pm BTW what does optimizing level 4? Never used it before.
No idea. :)
Qui trop embrasse mal étreint.

Author of Eschecs, a simple UCI chess GUI written in Pascal.