Page 1 of 1

Help compiling new Glaurung2 e/4

Posted: Fri Jun 08, 2007 9:40 pm
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.

Re: Help compiling new Glaurung2 e/4

Posted: Fri Jun 08, 2007 10:00 pm
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.

Re: Help compiling new Glaurung2 e/4

Posted: Fri Jun 08, 2007 11:01 pm
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

Re: Help compiling new Glaurung2 e/4

Posted: Sat Jun 09, 2007 12:40 am
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

Re: Help compiling new Glaurung2 e/4

Posted: Sat Jun 09, 2007 7:17 am
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.

Re: Help compiling new Glaurung2 e/4

Posted: Sat Jun 09, 2007 7:27 am
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

Re: Help compiling new Glaurung2 e/4

Posted: Sat Jun 09, 2007 7:28 am
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

Re: Help compiling new Glaurung2 e/4

Posted: Sat Jun 09, 2007 7:34 am
by Dann Corbit
P.S.
The mingw version is 4MB compared to 380K and 40% slower. Not recommended.

Re: Help compiling new Glaurung2 e/4

Posted: Sat Jun 09, 2007 11:50 am
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