Cutechess Compilation errors

Discussion of chess software programming and technical issues.

Moderator: Ras

phenri
Posts: 284
Joined: Tue Aug 13, 2013 9:44 am

Cutechess Compilation errors

Post by phenri »

Since cutechess stops working after a while, I decided to compile it.
But unfortunately I meet many difficulties. Here is the latest.

Code: Select all

src\tournament.cpp: In member function 'void Tournament::setResume(int)':
src\tournament.cpp:232:2: error: 'nextGame' was not declared in this scope
the source code from jeremy https://github.com/jeremybernstein/cutechess/
syzygy
Posts: 5944
Joined: Tue Feb 28, 2012 11:56 pm

Re: Cutechess Compilation errors

Post by syzygy »

Why not take the official source:
https://github.com/cutechess/cutechess

or better:
https://github.com/cutechess/cutechess/tree/cli-0.6.0

or send an e-mail to Jeremy telling him (...what he probably knows already).
phenri
Posts: 284
Joined: Tue Aug 13, 2013 9:44 am

Re: Cutechess Compilation errors

Post by phenri »

With the official version is even more errors.

Code: Select all

(...)
g++ -c -pipe -g -frtti -fexceptions -mthreads -Wall -Wextra -DUNICODE -DQT_LARGEFILE_SUPPORT -DLIB_EXPORT= -DZ_PREF
IX -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I
"c:\Qt\4.8.4\include\QtCore" -I"c:\Qt\4.8.4\include" -I"src" -I"components\json\src" -I"3rdparty\gtb\src" -I"c:\Qt\
4.8.4\include\ActiveQt" -I".moc" -I"c:\Qt\4.8.4\mkspecs\win32-g++" -o .obj\pipereader_win.o src\pipereader_win.cpp
src\pipereader_win.cpp: In member function 'qint64 PipeReader::readData(char*, qint64)':
src\pipereader_win.cpp:54:40: error: no matching function for call to 'qMin(long long int, int&)'
src\pipereader_win.cpp:54:40: note: candidate is:
In file included from c:\Qt\4.8.4\include/QtCore/qglobal.h:1:0,
                 from c:\Qt\4.8.4\include/QtCore/../../src/corelib/global/qnamespace.h:45,
                 from c:\Qt\4.8.4\include/QtCore/qnamespace.h:1,
                 from c:\Qt\4.8.4\include/QtCore/../../src/corelib/kernel/qobjectdefs.h:45,
                 from c:\Qt\4.8.4\include/QtCore/qobjectdefs.h:1,
                 from c:\Qt\4.8.4\include/QtCore/../../src/corelib/kernel/qobject.h:47,
                 from c:\Qt\4.8.4\include/QtCore/qobject.h:1,
                 from c:\Qt\4.8.4\include\QtCore/../../src/corelib/thread/qthread.h:45,
                 from c:\Qt\4.8.4\include\QtCore/qthread.h:1,
                 from c:\Qt\4.8.4\include\QtCore/QThread:1,
                 from src\pipereader_win.h:22,
                 from src\pipereader_win.cpp:18:
c:\Qt\4.8.4\include/QtCore/../../src/corelib/global/qglobal.h:1211:34: note: template<class T> const T& qMin(const
T&, const T&)
c:\Qt\4.8.4\include/QtCore/../../src/corelib/global/qglobal.h:1211:34: note:   template argument deduction/substitu
tion failed:
src\pipereader_win.cpp:54:40: note:   deduced conflicting types for parameter 'const T' ('long long int' and 'int')

src\pipereader_win.cpp: In member function 'virtual void PipeReader::run()':
src\pipereader_win.cpp:85:52: error: no matching function for call to 'qMin(int, long long int)'
src\pipereader_win.cpp:85:52: note: candidate is:
In file included from c:\Qt\4.8.4\include/QtCore/qglobal.h:1:0,
                 from c:\Qt\4.8.4\include/QtCore/../../src/corelib/global/qnamespace.h:45,
                 from c:\Qt\4.8.4\include/QtCore/qnamespace.h:1,
                 from c:\Qt\4.8.4\include/QtCore/../../src/corelib/kernel/qobjectdefs.h:45,
                 from c:\Qt\4.8.4\include/QtCore/qobjectdefs.h:1,
                 from c:\Qt\4.8.4\include/QtCore/../../src/corelib/kernel/qobject.h:47,
                 from c:\Qt\4.8.4\include/QtCore/qobject.h:1,
                 from c:\Qt\4.8.4\include\QtCore/../../src/corelib/thread/qthread.h:45,
                 from c:\Qt\4.8.4\include\QtCore/qthread.h:1,
                 from c:\Qt\4.8.4\include\QtCore/QThread:1,
                 from src\pipereader_win.h:22,
                 from src\pipereader_win.cpp:18:
c:\Qt\4.8.4\include/QtCore/../../src/corelib/global/qglobal.h:1211:34: note: template<class T> const T& qMin(const
T&, const T&)
c:\Qt\4.8.4\include/QtCore/../../src/corelib/global/qglobal.h:1211:34: note:   template argument deduction/substitu
tion failed:
src\pipereader_win.cpp:85:52: note:   deduced conflicting types for parameter 'const T' ('int' and 'long long int')

make[3]: *** [.obj/pipereader_win.o] Error 1
make[3]: Leaving directory `H:/GitHub/cutechess-master/projects/lib'
make[2]: *** [debug] Error 2
make[2]: Leaving directory `H:/GitHub/cutechess-master/projects/lib'
make[1]: *** [sub-lib-make_default-ordered] Error 2
make[1]: Leaving directory `H:/GitHub/cutechess-master/projects'
make: *** [sub-projects-make_default] Error 2
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Cutechess Compilation errors

Post by Sven »

phenri wrote:With the official version is even more errors.

Code: Select all

(...)
g++ -c -pipe -g -frtti -fexceptions -mthreads -Wall -Wextra -DUNICODE -DQT_LARGEFILE_SUPPORT -DLIB_EXPORT= -DZ_PREF
IX -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I
"c:\Qt\4.8.4\include\QtCore" -I"c:\Qt\4.8.4\include" -I"src" -I"components\json\src" -I"3rdparty\gtb\src" -I"c:\Qt\
4.8.4\include\ActiveQt" -I".moc" -I"c:\Qt\4.8.4\mkspecs\win32-g++" -o .obj\pipereader_win.o src\pipereader_win.cpp
src\pipereader_win.cpp: In member function 'qint64 PipeReader::readData(char*, qint64)':
src\pipereader_win.cpp:54:40: error: no matching function for call to 'qMin(long long int, int&)'
src\pipereader_win.cpp:54:40: note: candidate is:
In file included from c:\Qt\4.8.4\include/QtCore/qglobal.h:1:0,
                 from c:\Qt\4.8.4\include/QtCore/../../src/corelib/global/qnamespace.h:45,
                 from c:\Qt\4.8.4\include/QtCore/qnamespace.h:1,
                 from c:\Qt\4.8.4\include/QtCore/../../src/corelib/kernel/qobjectdefs.h:45,
                 from c:\Qt\4.8.4\include/QtCore/qobjectdefs.h:1,
                 from c:\Qt\4.8.4\include/QtCore/../../src/corelib/kernel/qobject.h:47,
                 from c:\Qt\4.8.4\include/QtCore/qobject.h:1,
                 from c:\Qt\4.8.4\include\QtCore/../../src/corelib/thread/qthread.h:45,
                 from c:\Qt\4.8.4\include\QtCore/qthread.h:1,
                 from c:\Qt\4.8.4\include\QtCore/QThread:1,
                 from src\pipereader_win.h:22,
                 from src\pipereader_win.cpp:18:
c:\Qt\4.8.4\include/QtCore/../../src/corelib/global/qglobal.h:1211:34: note: template<class T> const T& qMin(const
T&, const T&)
c:\Qt\4.8.4\include/QtCore/../../src/corelib/global/qglobal.h:1211:34: note:   template argument deduction/substitu
tion failed:
src\pipereader_win.cpp:54:40: note:   deduced conflicting types for parameter 'const T' ('long long int' and 'int')

src\pipereader_win.cpp: In member function 'virtual void PipeReader::run()':
src\pipereader_win.cpp:85:52: error: no matching function for call to 'qMin(int, long long int)'
src\pipereader_win.cpp:85:52: note: candidate is:
In file included from c:\Qt\4.8.4\include/QtCore/qglobal.h:1:0,
                 from c:\Qt\4.8.4\include/QtCore/../../src/corelib/global/qnamespace.h:45,
                 from c:\Qt\4.8.4\include/QtCore/qnamespace.h:1,
                 from c:\Qt\4.8.4\include/QtCore/../../src/corelib/kernel/qobjectdefs.h:45,
                 from c:\Qt\4.8.4\include/QtCore/qobjectdefs.h:1,
                 from c:\Qt\4.8.4\include/QtCore/../../src/corelib/kernel/qobject.h:47,
                 from c:\Qt\4.8.4\include/QtCore/qobject.h:1,
                 from c:\Qt\4.8.4\include\QtCore/../../src/corelib/thread/qthread.h:45,
                 from c:\Qt\4.8.4\include\QtCore/qthread.h:1,
                 from c:\Qt\4.8.4\include\QtCore/QThread:1,
                 from src\pipereader_win.h:22,
                 from src\pipereader_win.cpp:18:
c:\Qt\4.8.4\include/QtCore/../../src/corelib/global/qglobal.h:1211:34: note: template<class T> const T& qMin(const
T&, const T&)
c:\Qt\4.8.4\include/QtCore/../../src/corelib/global/qglobal.h:1211:34: note:   template argument deduction/substitu
tion failed:
src\pipereader_win.cpp:85:52: note:   deduced conflicting types for parameter 'const T' ('int' and 'long long int')

make[3]: *** [.obj/pipereader_win.o] Error 1
make[3]: Leaving directory `H:/GitHub/cutechess-master/projects/lib'
make[2]: *** [debug] Error 2
make[2]: Leaving directory `H:/GitHub/cutechess-master/projects/lib'
make[1]: *** [sub-lib-make_default-ordered] Error 2
make[1]: Leaving directory `H:/GitHub/cutechess-master/projects'
make: *** [sub-projects-make_default] Error 2
This one looks just like one single error: at two places in the code the qMin() function is used in a way that I would call non-portable. One function argument is the difference of two pointers which is of type ptrdiff_t, and on 64 bit systems this is not an "int" but a "long long int" which breaks the signature of qMin() where two arguments of identical types are expected. The fix should be a conversion like "int(ptr1-ptr2)" instead of "ptr1-ptr2".

Sven
phenri
Posts: 284
Joined: Tue Aug 13, 2013 9:44 am

Re: Cutechess Compilation errors

Post by phenri »

In 80% of cases, It's always the same story; the code works and compiles only in the machine of its author.

Thanks Sven for the help, but I can not find "ptr1-ptr2". Now I understand that it meant something else.

You can consider this thread as solved because I give up.
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Cutechess Compilation errors

Post by zullil »

phenri wrote:In 80% of cases, It's always the same story; the code works and compiles only in the machine of its author.

Thanks Sven for the help, but I can not find "ptr1-ptr2". Now I understand that it meant something else.

You can consider this thread as solved because I give up.
cutechess/projects/lib/src/pipereader_win.cpp

Try modifying as shown below near line 54 and near line 85.

Code: Select all

/*
    This file is part of Cute Chess.

    Cute Chess is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Cute Chess 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 Cute Chess.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "pipereader_win.h"
#include <QMutexLocker>


PipeReader::PipeReader(HANDLE pipe, QObject* parent)
	: QThread(parent),
	  m_pipe(pipe),
	  m_bufEnd(m_buf + BufSize),
	  m_start(m_buf),
	  m_end(m_buf),
	  m_freeBytes(BufSize),
	  m_usedBytes(0),
	  m_lastNewLine(1)
{
	Q_ASSERT(m_pipe != INVALID_HANDLE_VALUE);
}

qint64 PipeReader::bytesAvailable() const
{
	return qint64(m_usedBytes.available());
}

bool PipeReader::canReadLine() const
{
	QMutexLocker locker(&m_mutex);
	return m_lastNewLine <= m_usedBytes.available();
}

qint64 PipeReader::readData(char* data, qint64 maxSize)
{
	int n = qMin(int(maxSize), m_usedBytes.available());
	if (n <= 0)
		return -1;
	m_usedBytes.acquire(n);

	// Copy the first (possibly the only) block of data
	//int size1 = qMin(m_bufEnd - m_start, n);
        int size1 = qMin(int(m_bufEnd - m_start), n);
	memcpy(data, m_start, size_t(size1));
	m_start += size1;

	Q_ASSERT(m_start <= m_bufEnd);
	if (m_start == m_bufEnd)
		m_start = m_buf;

	// Copy the second block of data from the beginning
	int size2 = n - size1;
	if (size2 > 0)
	{
		memcpy(data + size1, m_start, size_t(size2));
		m_start += size2;

		Q_ASSERT(m_start <= m_bufEnd);
		if (m_start == m_bufEnd)
			m_start = m_buf;
	}
	Q_ASSERT(n == size1 + size2);

	m_freeBytes.release(n);
	return n;
}

void PipeReader::run()
{
	DWORD dwRead = 0;

	forever
	{
		//int maxSize = qMin(BufSize / 10, m_bufEnd - m_end);
                int maxSize = qMin(BufSize / 10, int(m_bufEnd - m_end));
		m_freeBytes.acquire(maxSize);

		BOOL ok = ReadFile(m_pipe, m_end, maxSize, &dwRead, 0);
		if (!ok || dwRead == 0)
		{
			DWORD err = GetLastError();
			if (err != ERROR_INVALID_HANDLE
			&&  err != ERROR_BROKEN_PIPE)
				qWarning("ReadFile failed with 0x%x", int(err));
			return;
		}

		m_end += dwRead;
		Q_ASSERT(m_end <= m_bufEnd);

		QMutexLocker locker(&m_mutex);

		m_lastNewLine += dwRead;
		for (int i = 1; i <= int(dwRead); i++)
		{
			if (*(m_end - i) == '\n')
			{
				m_lastNewLine = i;
				break;
			}
		}

		if (m_end == m_bufEnd)
			m_end = m_buf;

		m_freeBytes.release(maxSize - dwRead);
		m_usedBytes.release(dwRead);

		// To avoid signal spam, send the 'readyRead' signal only
		// if we have a whole line of new data
		if (m_lastNewLine <= int(dwRead))
			emit readyRead();
	}
}
phenri
Posts: 284
Joined: Tue Aug 13, 2013 9:44 am

Re: Cutechess Compilation errors

Post by phenri »

Thank Louis for the help. This has solved this error but then another occurred, then another and another...(QT4/5, pthreads, w32,lt, gtb, minGW, cygwin, crap, etc...)
Then finally I got a binary file. The problem now is that it makes an enormous size (debug I guess) and he claims DLL files.
Now I really resign for a while.

ps: I solved the bad behaviour with cutechess by setting restart to OFF. Problem solved. Thank you.