Help compiling new Glaurung2 e/4

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Denis P. Mendoza
Posts: 415
Joined: Fri Dec 15, 2006 9:46 pm
Location: Philippines

Help compiling new Glaurung2 e/4

Post by Denis P. Mendoza »

Using the makefile and GCC compiler, I got this error when compiling:
misc.cpp:43: error: `gettimeofday' undeclared (first use this function)
misc.cpp:43: error: (Each undeclared identifier is reported only once for each function it appears in.)
I also understand that it has to to be tweaked too to adapt to the Intel and MSVC 6 at the least - also a lot of errors. Any help on compiling Glaurung will do. Thanks.
User avatar
Jim Ablett
Posts: 1383
Joined: Fri Jul 14, 2006 7:56 am
Location: London, England
Full name: Jim Ablett

Re: Help compiling new Glaurung2 e/4

Post by Jim Ablett »

Hi Denis,

You can compile it with latest Cygwin Gcc. Try these 'CFLAGS' in the makefile >

CFLAGS = -O3 -g -march=athlon-xp -fstrict-aliasing -fno-exceptions -fno-rtti -Wall -fomit-frame-pointer -fexpensive-optimizations -ffast-math -funroll-loops -fprofile-generate

You can also compile it with the very latest bleeding edge Mingw Gcc (4.1.2/4.2.0)

http://www.tdragon.net/recentgcc.html

You can compile it with the win32 pthread library.

ftp://sourceware.org/pub/pthreads-win32/dll-latest

Change '-lpthread' in the makefile to 'lpthreadGC2'

Jim.
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: Help compiling new Glaurung2 e/4

Post by Tord Romstad »

Denis P. Mendoza wrote:Using the makefile and GCC compiler, I got this error when compiling:
misc.cpp:43: error: `gettimeofday' undeclared (first use this function)
misc.cpp:43: error: (Each undeclared identifier is reported only once for each function it appears in.)
I also understand that it has to to be tweaked too to adapt to the Intel and MSVC 6 at the least - also a lot of errors. Any help on compiling Glaurung will do. Thanks.
Hello Denis,

The "gettimeofday" function is a standard Unix function. A Windows version of this function is found in the file "timeoday.cpp", which is included in the Glaurung download (this file was not created by me, but by someone named Eric Backus; Dann Corbit sent it to me ages ago when he was porting some ancient Glaurung version to Windows). If you make sure to include the timeoday.cpp file when compiling Glaurung, I don't think you should see the error message you quote above. If you use the Makefile included with Glaurung, try adding a line with ".o/timeoday.o " under the section named "OBJ" in the Makefile. If this is not enough, try adding -D_MSC_VER to CFLAGS in the Makefile.

Perhaps this won't be enough, but I hope it will help you get started. Because I don't run Windows myself, I can't run any experiments.

Tord
User avatar
Denis P. Mendoza
Posts: 415
Joined: Fri Dec 15, 2006 9:46 pm
Location: Philippines

Re: Help compiling new Glaurung2 e/4

Post by Denis P. Mendoza »

Jim/Tord,

Many thanks for the tips and advices. I already tried the Dann Corbit tweaks which I've seen in the previous Glaurung 1.21 src, but to no avail, that's why I asked. My intermediate knowledge at the moment really needs advices from the experts.

Jim,

What would be the conditions/fixes, if I will use the Intel compiler and MSVC 2005. I would greatly appreciate these infos to improve my knowledge in adapting to different compiling environments.


Denis
Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Help compiling new Glaurung2 e/4

Post by Dann Corbit »

Denis P. Mendoza wrote:Jim/Tord,

Many thanks for the tips and advices. I already tried the Dann Corbit tweaks which I've seen in the previous Glaurung 1.21 src, but to no avail, that's why I asked. My intermediate knowledge at the moment really needs advices from the experts.

Jim,

What would be the conditions/fixes, if I will use the Intel compiler and MSVC 2005. I would greatly appreciate these infos to improve my knowledge in adapting to different compiling environments.


Denis
Using compiler:
Microsoft Visual Studio 2005
Version 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
Version 2.0.50727

Installed Edition: Enterprise


These are the compiler option flags:
/Ox /Ob2 /Oi /Ot /Oy /GT /GL /I "C:\Program Files\Microsoft SDK\Include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /GF /FD /EHsc /MT /Zp16 /GS- /Gy /fp:fast /Fp".\Release/glaurung.pch" /Fo".\Release/" /Fd".\Release/" /W4 /nologo /c /Gr /TP /wd4996 /errorReport:prompt

I do a profile guided optimization which includes the following:
Perform a 5 seconds run through WAC.
Perform a 10 minute analysis of WAC.230
Run 4 games at 5'+5"
Gather the .pgc files and rebuild.

If you want to build with Mingw or Cygwin GCC, you will either have to install pthreads or modify the source to recognize the environment.

You can find pthreads here:
http://sourceware.org/pthreads-win32/

I have done pthreads builds of Glaurung in the past and it works that way.
It is probably better to use native Win32 primitives though.
Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Help compiling new Glaurung2 e/4

Post by Dann Corbit »

To build under Mingw, first modify the makefile to look like this (I added timeoday.o reference and three DEFINE flags):

# Glaurung 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.

# You should have received a copy of the GNU General Public License
# along with Glaurung; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

CC = g++

#CFLAGS = -O3 -g -funroll-loops -fomit-frame-pointer -fstrict-aliasing -fno-exceptions -fno-rtti -Wall
CFLAGS = -O3 -g -DNDEBUG -funroll-loops -fomit-frame-pointer -fstrict-aliasing -fno-exceptions -fno-rtti -Wall
#CFLAGS = -O3 -DNDEBUG -funroll-loops -fomit-frame-pointer -fstrict-aliasing -fno-exceptions -fno-rtti -Wall -arch ppc
#CFLAGS = -O3 -DNDEBUG -funroll-loops -fomit-frame-pointer -fstrict-aliasing -fno-exceptions -fno-rtti -Wall -arch ppc -mcpu=G5 -mtune=G5 -fast

DEFINES = -D_MSC_VER -DASM_LOCK -DWIN32
LDFLAGS =

OBJ = .o/bitboard.o \
.o/color.o \
.o/pawns.o \
.o/material.o \
.o/endgame.o \
.o/evaluate.o \
.o/main.o \
.o/misc.o \
.o/move.o \
.o/movegen.o \
.o/history.o \
.o/movepick.o \
.o/search.o \
.o/piece.o \
.o/position.o \
.o/square.o \
.o/direction.o \
.o/timeoday.o \
.o/tt.o \
.o/value.o \
.o/uci.o \
.o/ucioption.o \
.o/mersenne.o \
.o/book.o \
.o/bitbase.o \
.o/test.o

glaurung: .o $(OBJ)
$(CC) $(CFLAGS) $(DEFINES) $(LDFLAGS) $(OBJ) -o glaurung -lm -lpthread

.o/%.o: Makefile %.cpp
$(CC) $(CFLAGS) $(DEFINES) -c $*.cpp -o .o/$*.o

.o:
mkdir .o

clean:
rm -rf .o glaurung
Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Help compiling new Glaurung2 e/4

Post by Dann Corbit »

The one other change needed to get it to work with Mingw is to add the following to the top of search.cpp, before any other headers are included:

#ifdef _MSC_VER
#include <windows.h>
#endif
Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Help compiling new Glaurung2 e/4

Post by Dann Corbit »

P.S.
The mingw version is 4MB compared to 380K and 40% slower. Not recommended.
User avatar
Denis P. Mendoza
Posts: 415
Joined: Fri Dec 15, 2006 9:46 pm
Location: Philippines

Re: Help compiling new Glaurung2 e/4

Post by Denis P. Mendoza »

Dann,

Thanks. The infos here would keep me preoccupied tonight till I get it right. I reformatted my old hardisk 3 months ago, and re-installed all my previous softwares. I probably forgot the posix threads needed for Windows.

I'll take it one bit at a time. Compiling it properly without errors must be the first step for all my available C++ compilers. PGO will come later.

Denis