Crafty v25.3 compile

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
jhaglund2
Posts: 23
Joined: Mon Jan 16, 2017 5:28 pm

Crafty v25.3 compile

Post by jhaglund2 » Mon Oct 08, 2018 6:53 pm

I'm back again trying to compile Crafty v25.3, with Microsoft VS 2017.

Warnings:
thread.c(455): warning C4028: formal parameter 1 different from declaration

Code: Select all

int ThreadSplit(TREE * tree, int ply, int depth, int alpha, int o_alpha, int done)
thread.c(888): warning C4028: formal parameter 1 different from declaration

Code: Select all

TREE *GetBlock(TREE * RESTRICT parent, int tid) {
book.c, line 1438 seems incorrect.

book.c(1438): error C2440: 'function': cannot convert from 'int (__fastcall *)(const void *,const void *)' to '_CoreCrtNonSecureSearchSortCompareFunction'

book.c(1438): warning C4024: 'qsort': different types for formal and actual parameter 4

Code: Select all

qsort((char *) buffer, number, sizeof(BB_POSITION), BookupCompare);
change: utility.c, line 2558

utility.c(2558): warning C4477: 'printf' : format string '%llu' requires an argument of type 'unsigned __int64', but variadic argument 1 has type 'DWORD'

Code: Select all

 printf("Current ideal CPU is %llu\n", dwCPU);
to

Code: Select all

 printf("Current ideal CPU is %lu\n", dwCPU);
change: utility.c, line 2591

Code: Select all

 printf("Starting thread on node " PRId64 " CPU mask %I64d\n", ulNumaNode,
to

Code: Select all

printf("Starting thread on node " PRId64 " CPU mask %ld\n", ulNumaNode,

tbcore.c(11): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
This needs a compatibility fix.

Code: Select all

#include <unistd.h>
option.c: lines 922, 964, 1001

option.c(922): error C2708: '__builtin_clzll': actual parameters length in bytes differs from previous call or reference

Code: Select all

hash_table_size = ((1ull) << MSB(new_hash_size)) / 16;
option.c(964): error C2708: '__builtin_clzll': actual parameters length in bytes differs from previous call or reference

Code: Select all

hash_path_size = ((1ull) << MSB(new_hash_size / sizeof(HPATH_ENTRY)));
option.c(1001): error C2708: '__builtin_clzll': actual parameters length in bytes differs from previous call or reference

Code: Select all

pawn_hash_table_size =   1ull << MSB(new_hash_size / sizeof(PAWN_HASH_ENTRY));

chess.h: lines 324,-326

Code: Select all

#define PopCnt(v) __builtin_popcountll(v)
#define LSB(v)    __builtin_ctzll(v)
#define MSB(v)    (63 - __builtin_clzll(v))
These are causing the compiler to error.

I think working on MacOs, Linux, GCC only, has lost compile compatibility with Windows.

Please address a fix.
Thanks!

jhaglund2
Posts: 23
Joined: Mon Jan 16, 2017 5:28 pm

Re: Crafty v25.3 compile

Post by jhaglund2 » Tue Oct 09, 2018 3:37 pm

Also:

error LNK2019: unresolved external symbol _sleep referenced in function _Iterate

iterate: line 182

Code: Select all

if (elo_sleep) sleep (time_limit/167);
Windows:

Code: Select all

if (elo_sleep) Sleep (time_limit/167);

Dann Corbit
Posts: 8844
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Crafty v25.3 compile

Post by Dann Corbit » Tue Oct 09, 2018 11:01 pm

jhaglund2 wrote:
Tue Oct 09, 2018 3:37 pm
Also:

error LNK2019: unresolved external symbol _sleep referenced in function _Iterate

iterate: line 182

Code: Select all

if (elo_sleep) sleep (time_limit/167);
Windows:

Code: Select all

if (elo_sleep) Sleep (time_limit/167);
Careful, they are not the same time units.

http://man7.org/linux/man-pages/man3/sleep.3.html
https://msdn.microsoft.com/en-us/library/ms918428.aspx
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.

jhaglund2
Posts: 23
Joined: Mon Jan 16, 2017 5:28 pm

Re: Crafty v25.3 compile

Post by jhaglund2 » Wed Oct 10, 2018 12:13 am

https://en.wikipedia.org/wiki/Sleep_(system_call)

Code: Select all

C examples
In Windows OS:
Sleep(2*1000);  // Sleep for 2 seconds

In Unix:
sleep(2);       // Sleep for 2 seconds

jdart
Posts: 3572
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: Crafty v25.3 compile

Post by jdart » Fri Oct 12, 2018 1:54 pm

Re the errors about unistd.h (tbcore.c(11) for example) - that doesn't really make sense to me. In the source I have that is not included if _WIN32 is defined, and MSVC should define that by default.

--Jon

Sven
Posts: 3653
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany
Full name: Sven Schüle
Contact:

Re: Crafty v25.3 compile

Post by Sven » Fri Oct 12, 2018 3:51 pm

jdart wrote:
Fri Oct 12, 2018 1:54 pm
Re the errors about unistd.h (tbcore.c(11) for example) - that doesn't really make sense to me. In the source I have that is not included if _WIN32 is defined, and MSVC should define that by default.

--Jon
Typically Crafty includes unistd.h and other POSIX headers within #if defined(UNIX).
Sven Schüle

jhaglund2
Posts: 23
Joined: Mon Jan 16, 2017 5:28 pm

Re: Crafty v25.3 compile

Post by jhaglund2 » Sat Oct 13, 2018 8:58 pm

After looking deeper into the problem, and many trials and changes, I managed to get Crafty v25.3 compiled, with Microsoft VS 2017. :lol:
However, I couldn't get /DSYZYGY to work, so it is without tablebase support for now.

crafty.obj : error LNK2019: unresolved external symbol _tb_init_impl referenced in function _Option
crafty.obj : error LNK2019: unresolved external symbol _tb_probe_wdl_impl referenced in function _Search
crafty.obj : error LNK2019: unresolved external symbol _tb_probe_root_impl referenced in function _RootMoveList
crafty.obj : error LNK2019: unresolved external symbol _TB_LARGEST referenced in function _Option

Also, I had to comment out:
book.c, line 1438

book.c(1438): error C2440: 'function': cannot convert from 'int (__fastcall *)(const void *,const void *)' to '_CoreCrtNonSecureSearchSortCompareFunction'
book.c(1438): warning C4024: 'qsort': different types for formal and actual parameter 4

Code: Select all

//qsort((char *) buffer, number, sizeof(BB_POSITION), BookupCompare);
Compiled for up to 64 CPUs. Give it a whirl.
https://www.mediafire.com/file/7e27pikd ... y.zip/file

jhaglund2
Posts: 23
Joined: Mon Jan 16, 2017 5:28 pm

Re: Crafty v25.3 compile

Post by jhaglund2 » Sat Oct 13, 2018 10:58 pm

Found the syntax error:

Code: Select all

qsort((char *) buffer, number, sizeof(BB_POSITION), BookupCompare);
to

Code: Select all

qsort((char *) buffer, number, sizeof(BB_POSITION), BookUpCompare);
Updated the file at the previous URL.

jhaglund2
Posts: 23
Joined: Mon Jan 16, 2017 5:28 pm

Re: Crafty v25.3 compile

Post by jhaglund2 » Mon Oct 15, 2018 7:47 am

By some miracle :shock: , I managed to (Microsoft VS 2017) compile with /DSYZYGY. It took a lot of changes. I'm not sure it even works as intended.

If someone could test it for me, that would be nice. :?:

https://www.mediafire.com/file/p0vfoawy ... b.zip/file

Post Reply