How to compile Polyglot under Windows?

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
KLc
Posts: 59
Joined: Wed Jun 03, 2020 4:46 am
Full name: Kurt Lanc

How to compile Polyglot under Windows?

Post by KLc » Thu Mar 04, 2021 3:21 pm

I have no experience with Windows. What exactly do I need (and need to do) to compile Polyglot (e.g. this version https://github.com/flok99/polyglot) under Windows? I installed Cygwin and was able to compile it via

Code: Select all

i686-pc-cygwin-gcc -m32 -s -O2 *.c -o polyglot.exe
But unfortunately, the program doesn't work properly: when feeding an ini file it raises "pipex_open():...Unable to parse command" error. I think a problem is the "_WIN32" macro which is not defined by Cygwin. Do I need to use MSVC? What exactly do I need to install here and how do I run the compilation? I hope someone can help me out here.

User avatar
hgm
Posts: 26134
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: How to compile Polyglot under Windows?

Post by hgm » Thu Mar 04, 2021 3:33 pm

I always use the command

make -f makefile.gcc

for compiling Polyglot under Cygwin. Polyglot does come with a Cygwin makefile. (At least the version I have in my repository.) But I am afraid this will work only on very old Cygwin versions; at some point Cygwin gcc cased supporting the -mno-cygwin option, which you need to make a .exe that can run on Windows without the cygwin1.dll present.

KLc
Posts: 59
Joined: Wed Jun 03, 2020 4:46 am
Full name: Kurt Lanc

Re: How to compile Polyglot under Windows?

Post by KLc » Thu Mar 04, 2021 4:05 pm

Thank you, I haven't noticed this file. As you said, I had to remove the -mno-cygwin flag. But I run into an error unfortunately:

Code: Select all

gcc -fpic -s  -lmsvcrt attack.o board.o book.o book_make.o book_merge.o colour.o engine.o epd.o fen.o game.o gui.o hash.o io.o ini.o line.o list.o main.o mainloop.o move.o move_do.o move_gen.o move_legal.o option.o parse.o pgheader.o pipex_win32.o pipex_posix.o pgn.o piece.o random.o san.o search.o square.o uci.o uci2uci.o util.o xboard2uci.o -o polyglot.exe
/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmsvcrt
/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: book_merge.o:book_merge.c:(.bss+0x0): multiple definition of `pgheader_magic'; book_make.o:book_make.c:(.bss+0x0): first defined here
/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: book_merge.o:book_merge.c:(.bss+0x8): multiple definition of `pgheader_version'; book_make.o:book_make.c:(.bss+0x8): first defined here
/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: pgheader.o:pgheader.c:(.data+0x0): multiple definition of `pgheader_magic'; book_make.o:book_make.c:(.bss+0x0): first defined here
/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: pgheader.o:pgheader.c:(.data+0x8): multiple definition of `pgheader_version'; book_make.o:book_make.c:(.bss+0x8): first defined here
collect2: error: ld returned 1 exit status
make: *** [makefile.gcc:26: polyglot.exe] Error 1

Code: Select all

$ gcc --version
gcc (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I also had to fix something in pgheader.c because I got an error:

Code: Select all

#ifdef _MSC_VER
  typedef unsigned __int64 uint64_t;
#else //added this part
	#if __WORDSIZE == 64
		typedef unsigned long int   uint64_t;
	#else
		__extension__
		typedef unsigned long long int  uint64_t;
	#endif
#endif
I currently don't see how I can get it to work. Maybe you have installed something else or additionally?! (I am running a 64-bit Windows 10 by the way).

User avatar
hgm
Posts: 26134
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: How to compile Polyglot under Windows?

Post by hgm » Thu Mar 04, 2021 4:36 pm

That it cannot find -lmsvcrt is related to that you are not doing a no-cygwin compile (it is a MicroSoft library), and probably also because you are compiling for 64 bit. You should not need the library, and can deleat that argument from the linking command.

The pgnheader symbols do not occur in the of Polyglot I supply with WinBoard, so I cannot see what is going wrong there.

KLc
Posts: 59
Joined: Wed Jun 03, 2020 4:46 am
Full name: Kurt Lanc

Re: How to compile Polyglot under Windows?

Post by KLc » Thu Mar 04, 2021 5:10 pm

Ugh, I took your version 2.0.4 from http://hgm.nubati.net/cgi-bin/gitweb.cg ... ;a=summary and that worked perfectly!! You must have cleaned up quite a bit of mess, thanks! Do you mind if I fork a version on Github eventually?

User avatar
hgm
Posts: 26134
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: How to compile Polyglot under Windows?

Post by hgm » Thu Mar 04, 2021 5:42 pm

Well, Polyglot carries a GPL license, so whether I mind or not is not really relevant! :lol:

But of course you are welcome.

KLc
Posts: 59
Joined: Wed Jun 03, 2020 4:46 am
Full name: Kurt Lanc

Re: How to compile Polyglot under Windows?

Post by KLc » Thu Mar 04, 2021 6:07 pm

hgm wrote:
Thu Mar 04, 2021 5:42 pm
Well, Polyglot carries a GPL license, so whether I mind or not is not really relevant! :lol:
Yes, I know, but I have some futher social standards. Thanks!

KLc
Posts: 59
Joined: Wed Jun 03, 2020 4:46 am
Full name: Kurt Lanc

Re: How to compile Polyglot under Windows?

Post by KLc » Thu Mar 04, 2021 6:33 pm

Oh, I'm sorry for being stupid, but how do I actually clone the repo on http://hgm.nubati.net/cgi-bin/gitweb.cg ... ;a=summary? I'm not familiar with this web interface. Sorry.

User avatar
hgm
Posts: 26134
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: How to compile Polyglot under Windows?

Post by hgm » Fri Mar 05, 2021 5:42 pm

I am not sure it can be cloned from the web interface . (I never tried that.) But the web interface just presents the directories with the git repositories that are also in the public server tree. Perhaps you can clone it from there:

http://hgm.nubati.net/git/polyglot.git/

KLc
Posts: 59
Joined: Wed Jun 03, 2020 4:46 am
Full name: Kurt Lanc

Re: How to compile Polyglot under Windows?

Post by KLc » Fri Mar 05, 2021 7:01 pm

hgm wrote:
Fri Mar 05, 2021 5:42 pm
I am not sure it can be cloned from the web interface . (I never tried that.) But the web interface just presents the directories with the git repositories that are also in the public server tree. Perhaps you can clone it from there:

http://hgm.nubati.net/git/polyglot.git/
Thanks for the reply. I read about the web interface. I think you can only provide the full repo by a server-side command. But never mind. I simply started from your 2.0.4 and import my changes. That's all good.

Post Reply