Alex2262 / AltairChessEngine

A strong chess engine made in c++
MIT License
56 stars 5 forks source link

some compilation error #119

Closed tissatussa closed 1 year ago

tissatussa commented 1 year ago

after a git clone of your newest source (upto PR 118) i get an error during compilation, see my terminal output below. btw. i (re)created the makefile by the command cmake . and then i did make. [ i'm on Xubuntu 22.04 ]

roelof@roelof-HP-Elite-x2-1012-G2:~/Compiled/AltairChessEngine$ make
[  7%] Building CXX object CMakeFiles/Altair.dir/src/main.cpp.o
[ 14%] Building CXX object CMakeFiles/Altair.dir/src/move.cpp.o
[ 21%] Building CXX object CMakeFiles/Altair.dir/src/perft.cpp.o
[ 28%] Building CXX object CMakeFiles/Altair.dir/src/position.cpp.o
[ 35%] Building CXX object CMakeFiles/Altair.dir/src/search.cpp.o
[ 42%] Building CXX object CMakeFiles/Altair.dir/src/useful.cpp.o
[ 50%] Building CXX object CMakeFiles/Altair.dir/src/uci.cpp.o
[ 57%] Building CXX object CMakeFiles/Altair.dir/src/bench.cpp.o
[ 64%] Building CXX object CMakeFiles/Altair.dir/src/see.cpp.o
[ 71%] Building CXX object CMakeFiles/Altair.dir/src/bitboard.cpp.o
[ 78%] Building CXX object CMakeFiles/Altair.dir/src/evaluation.cpp.o
[ 85%] Building CXX object CMakeFiles/Altair.dir/src/move_ordering.cpp.o
[ 92%] Building CXX object CMakeFiles/Altair.dir/src/datagen.cpp.o
/home/roelof/Compiled/AltairChessEngine/src/datagen.cpp: In member function ‘std::string Datagen::write_fen(Datagen_Thread&, std::string&, double)’:
/home/roelof/Compiled/AltairChessEngine/src/datagen.cpp:61:77: error: no match for ‘operator-’ (operand types are ‘std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >’ and ‘std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long int, std::ratio<1, 1000000000> > >’)
   60 |         auto ms_int = std::chrono::duration_cast<std::chrono::milliseconds>(end_time_point
      |                                                                             ~~~~~~~~~~~~~~
      |                                                                             |
      |                                                                             time_point<std::chrono::_V2::system_clock,[...]>
   61 |                                                                             - datagen_thread.start_time_point);
      |                                                                             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                                              |
      |                                                                                              time_point<std::chrono::_V2::steady_clock,[...]>
Alex2262 commented 1 year ago

Hi, thank you for noticing this issue. It was an issue that didn't produce any errors on my mac so I didn't catch it earlier, but it should be fixed now.

tissatussa commented 1 year ago

indeed it is fixed : now i succeed compiling a binary v4.3.9 ! but wonder .. in the README you state :

Altair can also be built from the source code with cmake, using the CMakeLists.txt, and make, using the makefile.

at first, as i wrote, i re-created a makefile by cmake . .. then make gives me a binary of 7.3 Mb, which is big compared to the 303.8 Kb binary i get when using your supplied makefile !? Both run fine and show v4.3.9

Alex2262 commented 1 year ago

To clarify, your own created makefile is generating a larger exe? If so, I would be unsure as to why this is happening. On my mac, the cmakelists and makefile generate an exe that is about the same size. If you are statically linking libraries, it will link these libraries into the executable at compile time which will produce a much larger exe size.

tissatussa commented 1 year ago

If you are statically linking libraries..

how could i ? i just use the makefile generated by cmake, without editing anything (except disabling the supplied makefile by temporarily renaming it).

tissatussa commented 1 year ago

To clarify, your own created makefile is generating a larger exe..

yes

Alex2262 commented 1 year ago

If you are statically linking libraries..

how could i ? i just use the makefile generated by cmake, without editing anything (except disabling the supplied makefile by temporarily renaming it).

If you are just directly using the cmakelists without any edit, then it may be building the exe in debug mode. To check this you can just run Altair by typing bench and comparing the nps to the exe created with the provided makefile. If it is being built in debug mode the exe may be bigger, and definitely slower. You can type set(CMAKE_BUILD_TYPE Release) at around line 7 of the CMakelists in order to build a release mode executable.

tissatussa commented 1 year ago

thanks for this detailed info ! i'm not too familiar with C++, i will try your edit .. Btw. i never did edit any CMakelists file, i always thought the cmake process would create a custom makefile for the concerning computer and its hardware .. does some argument exists for the cmake command to achieve what you suggest around line 7 ? Often a make command excepts such arguments also ..

tissatussa commented 1 year ago

doing set(CMAKE_BUILD_TYPE Release) gave no smaller binary, it's still 7.3 Mb .. the if statement "around line 7" is like this (in fact at lines 9 10 and 11) :

# Default build type
if(NOT CMAKE_BUILD_TYPE)
        set(CMAKE_BUILD_TYPE Release)
endif()

when removing the if-else clause, only leaving the set(..) command, nothing changes : "Release" is built !? I did not yet try bench ..

Alex2262 commented 1 year ago

Ok. I am not too sure then. Thanks for pointing this out, if I figure anything out I will let you know, but for now the makefile I have created should work adequately.