Newbie problems trying to compile Stockfish on Windows

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Theo H.
Posts: 8
Joined: Wed Jul 08, 2015 4:45 pm
Location: Germany
Full name: Theodor Heinze

Newbie problems trying to compile Stockfish on Windows

Post by Theo H. »

Hi all,

I am following the instructions on the Stockfish page which look very easygoing:

http://support.stockfishchess.org/kb/ad ... on-windows

I've installed MinGW successfully and run the "make" script.

Now, have a look at the error in the compilation process, please.

Code: Select all

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\>cd Stockfish

C:\Stockfish>cd src

C:\Stockfish\src>make profile-build ARCH=x86-32 COMP=mingw
make ARCH=x86-32 COMP=mingw config-sanity
make[1]: Entering directory `/c/Stockfish/src'

Config:
debug: 'no'
optimize: 'yes'
arch: 'i386'
bits: '32'
prefetch: 'yes'
bsfq: 'no'
popcnt: 'no'
sse: 'yes'
pext: 'no'

Flags:
CXX: g++
CXXFLAGS: -Wall -Wcast-qual -fno-exceptions -fno-rtti -std=c++11  -Wextra -Wshad
ow -DNDEBUG -O3 -msse
LDFLAGS:  -static

Testing config sanity. If this fails, try 'make help' ...

make[1]: Leaving directory `/c/Stockfish/src'

Step 0/4. Preparing for profile build.
make ARCH=x86-32 COMP=mingw gcc-profile-prepare
make[1]: Entering directory `/c/Stockfish/src'
make ARCH=x86-32 COMP=mingw gcc-profile-clean
make[2]: Entering directory `/c/Stockfish/src'
make[2]: Leaving directory `/c/Stockfish/src'
make[1]: Leaving directory `/c/Stockfish/src'

Step 1/4. Building executable for benchmark ...
make ARCH=x86-32 COMP=mingw gcc-profile-make
make[1]: Entering directory `/c/Stockfish/src'
make ARCH=x86-32 COMP=mingw \
        EXTRACXXFLAGS='-fprofile-generate' \
        EXTRALDFLAGS='-lgcov' \
        all
make[2]: Entering directory `/c/Stockfish/src'
g++ -Wall -Wcast-qual -fno-exceptions -fno-rtti -std=c++11 -fprofile-generate -W
extra -Wshadow -DNDEBUG -O3 -msse   -c -o benchmark.o benchmark.cpp
In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\cmath:44:0,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\random:38,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algo.h
:65,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\algorithm:62,
                 from movepick.h:24,
                 from thread.h:32,
                 from benchmark.cpp:29:
c:\mingw\include\math.h: In function 'float hypotf(float, float)':
c:\mingw\include\math.h:635:30: error: '_hypot' was not declared in this scope
 { return (float)(_hypot (x, y)); }
                              ^
Google search says this is actually a problem with MinGW!
The work-around is to add -D__NO_INLINE__ to the compile time options, to hide the offending inline function implementation.
http://ehc.ac/p/mingw/bugs/2250/

Is this the right solution and if it is, how do I add that to the compile time options?

Kind Regards
Theo
User avatar
Eelco de Groot
Posts: 4561
Joined: Sun Mar 12, 2006 2:40 am
Full name:   

Re: Newbie problems trying to compile Stockfish on Windows

Post by Eelco de Groot »

Hello Theo,

I don't think I can offer much insight. But what you quote, seems to be an older message. And the last three messages are more recent. It seems to be an issue that should already be fixed now, at least in the (MinGW?) repository. Issue 2250 is a duplicate of issue #2266 as we can read. Maybe somebody can confirm this but could it be something like an older copy you have of math.h? And that math.h is using _hypot which is not standard C++ hence the error. But maybe I am reading the comments wrong.

Anyway, welcome to the Stockfish community!

Eelco
Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it.
-- Brian W. Kernighan
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: Newbie problems trying to compile Stockfish on Windows

Post by MikeB »

Normally I would not suggest this in this forum, but since you are self described newbie, just double check that you are using the 32 bit version of mingw. I'm not a mingw user, but I found that same error condition you noted with somebody else that was trying to compile 32 bit stockfish with a 64 bit mingw. I believe the command might be "gcc --version" . I believe there are cross compiling options with stockfish, but I'm not familiar with them.

edit: Try building the 64 bit stockfish and see it works with your current mingw ;>)
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: Newbie problems trying to compile Stockfish on Windows

Post by JoshPettus »

does mingw not allow the -m32 flag?
Theo H.
Posts: 8
Joined: Wed Jul 08, 2015 4:45 pm
Location: Germany
Full name: Theodor Heinze

Re: Newbie problems trying to compile Stockfish on Windows

Post by Theo H. »

I asked Windows to find me that "math.h" so I could replace it with a newer version from the Internet, it didn't work out.

"gcc --version" says its
> gcc (GCC) 4.8.1

I downloaded MinGW exactly as stated in the Stockfish-tutorial, so it should be 32bit.

I tried compiling with the 64bit make order and got the same hypot-error.

Code: Select all

c:\Stockfish\src>gcc --version
gcc (GCC) 4.8.1
Copyright (C) 2013 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.


c:\Stockfish\src>make profile-build ARCH=x86-64 COMP=mingw
make ARCH=x86-64 COMP=mingw config-sanity
make[1]: Entering directory `/c/Stockfish/src'

Config:
debug: 'no'
optimize: 'yes'
arch: 'x86_64'
bits: '64'
prefetch: 'yes'
bsfq: 'yes'
popcnt: 'no'
sse: 'yes'
pext: 'no'

Flags:
CXX: g++
CXXFLAGS: -Wall -Wcast-qual -fno-exceptions -fno-rtti -std=c++11  -Wextra -Wshadow -DNDEBUG -O3 -DIS_64BIT -msse -DUSE_BSFQ
LDFLAGS:  -static

Testing config sanity. If this fails, try 'make help' ...

make[1]: Leaving directory `/c/Stockfish/src'

Step 0/4. Preparing for profile build.
make ARCH=x86-64 COMP=mingw gcc-profile-prepare
make[1]: Entering directory `/c/Stockfish/src'
make ARCH=x86-64 COMP=mingw gcc-profile-clean
make[2]: Entering directory `/c/Stockfish/src'
make[2]: Leaving directory `/c/Stockfish/src'
make[1]: Leaving directory `/c/Stockfish/src'

Step 1/4. Building executable for benchmark ...
make ARCH=x86-64 COMP=mingw gcc-profile-make
make[1]: Entering directory `/c/Stockfish/src'
make ARCH=x86-64 COMP=mingw \
        EXTRACXXFLAGS='-fprofile-generate' \
        EXTRALDFLAGS='-lgcov' \
        all
make[2]: Entering directory `/c/Stockfish/src'
g++ -Wall -Wcast-qual -fno-exceptions -fno-rtti -std=c++11 -fprofile-generate -Wextra -Wshadow -DNDEBUG -O3 -DIS_64BIT -msse -DUSE_BSFQ   -c -o benchmark.o benc
hmark.cpp
In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\cmath:44:0,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\random:38,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algo.h:65,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\algorithm:62,
                 from movepick.h:24,
                 from thread.h:32,
                 from benchmark.cpp:29:
c:\mingw\include\math.h: In function 'float hypotf(float, float)':
c:\mingw\include\math.h:635:30: error: '_hypot' was not declared in this scope
 { return (float)(_hypot (x, y)); }
                              ^
In file included from thread.h:36:0,
                 from benchmark.cpp:29:
thread_win32.h: At global scope:
thread_win32.h:61:9: error: 'condition_variable_any' in namespace 'std' does not name a type
 typedef std::condition_variable_any ConditionVariable;
         ^
In file included from benchmark.cpp:29:0:
thread.h:46:3: error: 'thread' in namespace 'std' does not name a type
   std::thread nativeThread;
   ^
thread.h:48:3: error: 'ConditionVariable' does not name a type
   ConditionVariable sleepCondition;
   ^
benchmark.cpp: In function 'void benchmark(const Position&, std::istream&)':
benchmark.cpp:110:35: error: 'stoi' was not declared in this scope
       limits.movetime = stoi(limit); // movetime is in millisecs
                                   ^
benchmark.cpp:113:32: error: 'stoi' was not declared in this scope
       limits.nodes = stoi(limit);
                                ^
benchmark.cpp:116:31: error: 'stoi' was not declared in this scope
       limits.mate = stoi(limit);
                               ^
benchmark.cpp:119:32: error: 'stoi' was not declared in this scope
       limits.depth = stoi(limit);
                                ^
make[2]: *** [benchmark.o] Error 1
make[2]: Leaving directory `/c/Stockfish/src'
make[1]: *** [gcc-profile-make] Error 2
make[1]: Leaving directory `/c/Stockfish/src'
make: *** [profile-build] Error 2

Theo H.
Posts: 8
Joined: Wed Jul 08, 2015 4:45 pm
Location: Germany
Full name: Theodor Heinze

Re: Newbie problems trying to compile Stockfish on Windows

Post by Theo H. »

Eelco de Groot wrote: Anyway, welcome to the Stockfish community!
I guess I am not there until I got it compiled at least one time :-)

Thanks anyway :-)
User avatar
Eelco de Groot
Posts: 4561
Joined: Sun Mar 12, 2006 2:40 am
Full name:   

Re: Newbie problems trying to compile Stockfish on Windows

Post by Eelco de Groot »

Hi Theo,

If I understand correctly, also from your output, that you are trying to build the 32 bit Stockfish. I had not really seen that. If you have a 64 bit Windows, this is not necessary but probably, like me, you have a 32 bit Windows. I have not encountered this specific error message though. But there were problems when Stockfish code was ported to C++11. I was not able to build a 32 bit Stockfish just following the instructions from Daylen Yang, after the port to C++11.

I was lucky that somebody found me a compiler that could build Stockfish 32 bit with the new C++11 code base. I posted my question in the Fishcooking group and got some great help from Vince.

Some things were a little different with the new compiler. For instance I had to move the sources to my /Documents folder, I could not navigate to just any folder anymore. Afterwards somebody found a compiler that was presumably faster, but I have not tried that one myself. 32 bit Stockfish build will always be a bit slower than the 64 bits build anyway.

Maybe you learn something you can use reading that original thread, there was recently a new post added. https://groups.google.com/forum/?fromgr ... DAeKCTpNE4

Sorry for the link, the Talkchess forum software won't accept some of the characters used by Google, so you have to copy and paste the whole line in your browser.

If you ask your question there, I am sure the knowledgeable compiler gurus would read it. The search function is not that easy but it usually is possible to find information with it in old threads.

You will get there, I am sure!

Eelco
Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it.
-- Brian W. Kernighan
User avatar
Jim Ablett
Posts: 1383
Joined: Fri Jul 14, 2006 7:56 am
Location: London, England
Full name: Jim Ablett

Re: Newbie problems trying to compile Stockfish on Windows

Post by Jim Ablett »

GCC 4.8.1 is too old. Use newer Posix enabled version.

http://sourceforge.net/projects/mingw-w ... ads-posix/

Jim.
BBauer
Posts: 658
Joined: Wed Mar 08, 2006 8:58 pm

Re: Newbie problems trying to compile Stockfish on Windows

Post by BBauer »

Well, I tried to upgrade to gcc5.3
I have

Code: Select all

C:\MinGW>ls
bin  libexec  mingw32  mingw64  msys  share  var
When I do

Code: Select all

make build ARCH=x86-64-modern COMP=mingw
make ARCH=x86-64-modern COMP=mingw config-sanity
make[1]: Entering directory `/c/Users/bbauer/linscott/mysrc'

Config:
debug: 'no'
optimize: 'yes'
arch: 'x86_64'
bits: '64'
prefetch: 'yes'
bsfq: 'yes'
popcnt: 'yes'
sse: 'yes'
pext: 'no'

Flags:
CXX: g++
CXXFLAGS: -Wall -Wcast-qual -fno-exceptions -fno-rtti -std=c++11  -Wextra -Wshadow -DNDEBUG -Ofast -march=native -mtune=native -flto -DIS_64BIT  -DUSE_BSFQ -mpopcnt -DUSE_POPCNT
LDFLAGS:  -flto -shared-libstdc++

Testing config sanity. If this fails, try 'make help' ...

make[1]: Leaving directory `/c/Users/bbauer/linscott/mysrc'
make ARCH=x86-64-modern COMP=mingw all
make[1]: Entering directory `/c/Users/bbauer/linscott/mysrc'
g++ -Wall -Wcast-qual -fno-exceptions -fno-rtti -std=c++11  -Wextra -Wshadow -DNDEBUG -Ofast -march=native -mtune=native -flto -DIS_64BIT  -DUSE_BSFQ -mpopcnt -DUSE_POPCNT   -c -o search.o search.cpp
In file included from thread.h:36:0,
                 from timeman.h:26,
                 from search.cpp:33:
thread_win32.h:61:14: error: 'condition_variable_any' in namespace 'std' does not name a type
 typedef std::condition_variable_any ConditionVariable;
              ^
In file included from timeman.h:26:0,
                 from search.cpp:33:
thread.h:46:8: error: 'thread' in namespace 'std' does not name a type
   std::thread nativeThread;
        ^
thread.h:48:3: error: 'ConditionVariable' does not name a type
   ConditionVariable sleepCondition;
   ^
make[1]: *** [search.o] Error 1
make[1]: Leaving directory `/c/Users/bbauer/linscott/mysrc'
make: *** [build] Error 2
Any Ideas?
Kind regards
Bernhard
User avatar
Jim Ablett
Posts: 1383
Joined: Fri Jul 14, 2006 7:56 am
Location: London, England
Full name: Jim Ablett

Re: Newbie problems trying to compile Stockfish on Windows

Post by Jim Ablett »

looks like you are using non-posix version of Mingw

Jim.