Compiling Stockfish with gcc on Termux

Moderators: Elijah, Igbo, timetraveller

kramnik

Top contribute Forum
Forum Contributions
Points: 40 305,00 
Posts: 1924
Joined: 04/11/2019, 14:45
Status: Offline (Active 3 Months, 5 Days, 16 Hours, 56 Minutes ago)
Medals: 1
Topics: 71
Reputation: 2388
Location: North-Italy
Has thanked: 1185 times
Been thanked: 2951 times

Re: Compiling Stockfish with gcc on Termux

Post by kramnik »

I did it, but there is no bashrc:

Code: Select all

~ $ ls -a
.  ..  .bash_history  .termux  Stockfish-Polyglot  storage
Archimedes wrote: 27/01/2022, 9:10 Look for .bashrc in your home directory and add the line with the export command to it.
LittleJoe

Top contribute Forum Engines Maker
Forum Contributions
Points: 14 078,00 
Posts: 327
Joined: 17/10/2020, 22:28
Status: Offline (Active 5 Days, 2 Hours, 20 Minutes ago)
Medals: 2
Topics: 5
Reputation: 506
Has thanked: 349 times
Been thanked: 671 times

Re: Compiling Stockfish with gcc on Termux

Post by LittleJoe »

kramnik wrote: 27/01/2022, 14:22 I did it, but there is no bashrc:
Why not create '.bashrc' in the home-directory with an editor and write this export line in it? It will work!
kramnik

Top contribute Forum
Forum Contributions
Points: 40 305,00 
Posts: 1924
Joined: 04/11/2019, 14:45
Status: Offline (Active 3 Months, 5 Days, 16 Hours, 56 Minutes ago)
Medals: 1
Topics: 71
Reputation: 2388
Location: North-Italy
Has thanked: 1185 times
Been thanked: 2951 times

Re: Compiling Stockfish with gcc on Termux

Post by kramnik »

Hm! Nice idea!
LittleJoe wrote: 27/01/2022, 14:46
kramnik wrote: 27/01/2022, 14:22 I did it, but there is no bashrc:
Why not create '.bashrc' in the home-directory with an editor and write this export line in it? It will work!
kramnik

Top contribute Forum
Forum Contributions
Points: 40 305,00 
Posts: 1924
Joined: 04/11/2019, 14:45
Status: Offline (Active 3 Months, 5 Days, 16 Hours, 56 Minutes ago)
Medals: 1
Topics: 71
Reputation: 2388
Location: North-Italy
Has thanked: 1185 times
Been thanked: 2951 times

Re: Compiling Stockfish with gcc on Termux

Post by kramnik »

IT WORKS! :argh: :sm73: :sm178:
LittleJoe wrote: 27/01/2022, 14:46
kramnik wrote: 27/01/2022, 14:22 I did it, but there is no bashrc:
Why not create '.bashrc' in the home-directory with an editor and write this export line in it? It will work!
kramnik

Top contribute Forum
Forum Contributions
Points: 40 305,00 
Posts: 1924
Joined: 04/11/2019, 14:45
Status: Offline (Active 3 Months, 5 Days, 16 Hours, 56 Minutes ago)
Medals: 1
Topics: 71
Reputation: 2388
Location: North-Italy
Has thanked: 1185 times
Been thanked: 2951 times

Re: Compiling Stockfish with gcc on Termux

Post by kramnik »

Trying to compile BrainLearn 17 on Termux with GCC. It looks lile this system doesn't work...

Code: Select all

search.cpp:46:10: fatal error: curl/curl.h: No such file or directory
   46 | #include <curl/curl.h>
      |          ^~~~~~~~~~~~~
leonhurricaneX wrote: 08/11/2021, 2:41 Static version of curl is already available in Termux.
Use pkg install libcurl-static
Archimedes

Android Engines Top Active Users
Forum Contributions
Points: 42 582,00 
Posts: 2059
Joined: 04/11/2019, 21:13
Status: Online (Active 2 Hours, 38 Minutes ago)
Medals: 2
Topics: 158
Reputation: 7111
Been thanked: 6477 times

Re: Compiling Stockfish with gcc on Termux

Post by Archimedes »

kramnik wrote: 06/05/2022, 17:50 Trying to compile BrainLearn 17 on Termux with GCC. It looks lile this system doesn't work...

Code: Select all

search.cpp:46:10: fatal error: curl/curl.h: No such file or directory
   46 | #include <curl/curl.h>
      |          ^~~~~~~~~~~~~
leonhurricaneX wrote: 08/11/2021, 2:41 Static version of curl is already available in Termux.
Use pkg install libcurl-static

Code: Select all

#include "/data/data/com.termux/files/usr/include/curl/curl.h"
kramnik

Top contribute Forum
Forum Contributions
Points: 40 305,00 
Posts: 1924
Joined: 04/11/2019, 14:45
Status: Offline (Active 3 Months, 5 Days, 16 Hours, 56 Minutes ago)
Medals: 1
Topics: 71
Reputation: 2388
Location: North-Italy
Has thanked: 1185 times
Been thanked: 2951 times

Re: Compiling Stockfish with gcc on Termux

Post by kramnik »

Code: Select all

mcts/montecarlo.cpp: In member function 'bool Stockfish::MonteCarlo::computational_budget() const':
mcts/montecarlo.cpp:229:6: error: 'dynamic_cast' not permitted with '-fno-rtti'
  229 |      dynamic_cast<MainThread*>(pos.this_thread())->check_time();
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [<builtin>: montecarlo.o] Error 1
Archimedes wrote: 06/05/2022, 20:23

Code: Select all

#include "/data/data/com.termux/files/usr/include/curl/curl.h"
Archimedes

Android Engines Top Active Users
Forum Contributions
Points: 42 582,00 
Posts: 2059
Joined: 04/11/2019, 21:13
Status: Online (Active 2 Hours, 38 Minutes ago)
Medals: 2
Topics: 158
Reputation: 7111
Been thanked: 6477 times

Re: Compiling Stockfish with gcc on Termux

Post by Archimedes »

You are one step further. Now add -frtti to CXXFLAGS.

By the way, you will find a working makefile for BrainLearn in my CECSA script. Compare it with the original makefile.
kramnik

Top contribute Forum
Forum Contributions
Points: 40 305,00 
Posts: 1924
Joined: 04/11/2019, 14:45
Status: Offline (Active 3 Months, 5 Days, 16 Hours, 56 Minutes ago)
Medals: 1
Topics: 71
Reputation: 2388
Location: North-Italy
Has thanked: 1185 times
Been thanked: 2951 times

Re: Compiling Stockfish with gcc on Termux

Post by kramnik »

Used your Makefile:

Code: Select all

/data/data/com.termux/files/cctools-toolchain/lib/gcc/aarch64-linux-android/10/../../../../aarch64-linux-android/bin/ld: cannot find -ldl
/data/data/com.termux/files/cctools-toolchain/lib/gcc/aarch64-linux-android/10/../../../../aarch64-linux-android/bin/ld: cannot find -lcrypto
/data/data/com.termux/files/cctools-toolchain/lib/gcc/aarch64-linux-android/10/../../../../aarch64-linux-android/bin/ld: cannot find -lnghttp2
/data/data/com.termux/files/cctools-toolchain/lib/gcc/aarch64-linux-android/10/../../../../aarch64-linux-android/bin/ld: cannot find -lssh2
/data/data/com.termux/files/cctools-toolchain/lib/gcc/aarch64-linux-android/10/../../../../aarch64-linux-android/bin/ld: cannot find -lssl
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:925: stockfish] Error 1
make[2]: Leaving directory '/data/data/com.termux/files/home/brainlearn'
make[1]: *** [Makefile:942: gcc-profile-make] Error 2
make[1]: Leaving directory '/data/data/com.termux/files/home/brainlearn'
make: *** [Makefile:797: profile-build] Error 2
Archimedes wrote: 07/05/2022, 10:13 You are one step further. Now add -frtti to CXXFLAGS.

By the way, you will find a working makefile for BrainLearn in my CECSA script. Compare it with the original makefile.
Archimedes

Android Engines Top Active Users
Forum Contributions
Points: 42 582,00 
Posts: 2059
Joined: 04/11/2019, 21:13
Status: Online (Active 2 Hours, 38 Minutes ago)
Medals: 2
Topics: 158
Reputation: 7111
Been thanked: 6477 times

Re: Compiling Stockfish with gcc on Termux

Post by Archimedes »

Now you must install all the missing static libraries. Don't know all package names. "pkg search" is your friend.

One of the needed package was ndk-multilib. Another needed package was openssl-static. And another were libnghttp2-static and libssh2-static. Install it and see what libraries are still missing during compilation. We will find the missing libraries.
superbatil
Forum Contributions
Points: 14 010,00 
Posts: 76
Joined: 24/02/2022, 11:23
Status: Offline (Active 1 Week, 6 Days, 4 Hours, 32 Minutes ago)
Topics: 0
Reputation: 17
Has thanked: 1 time
Been thanked: 51 times

Re: Compiling Stockfish with gcc on Termux

Post by superbatil »

Archimedes wrote: 07/05/2022, 14:36 Now you must install all the missing static libraries. Don't know all package names. "pkg search" is your friend.

One of the needed package was ndk-multilib. Another needed package was openssl-static. And another were libnghttp2-static and libssh2-static. Install it and see what libraries are still missing during compilation. We will find the missing libraries.
Sir,
Where can I find complete list or tutorial of CXXFLAG, CFLAG, LDFLAG?
Archimedes

Android Engines Top Active Users
Forum Contributions
Points: 42 582,00 
Posts: 2059
Joined: 04/11/2019, 21:13
Status: Online (Active 2 Hours, 38 Minutes ago)
Medals: 2
Topics: 158
Reputation: 7111
Been thanked: 6477 times

Re: Compiling Stockfish with gcc on Termux

Post by Archimedes »

superbatil wrote: 10/05/2022, 10:23Where can I find complete list or tutorial of CXXFLAG, CFLAG, LDFLAG?
https://gcc.gnu.org/
http://gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html
Archimedes

Android Engines Top Active Users
Forum Contributions
Points: 42 582,00 
Posts: 2059
Joined: 04/11/2019, 21:13
Status: Online (Active 2 Hours, 38 Minutes ago)
Medals: 2
Topics: 158
Reputation: 7111
Been thanked: 6477 times

Re: Compiling Stockfish with gcc on Termux

Post by Archimedes »

For clarification, if you receive warning messages about missing profiles during the compilation process with PGO, add the function __gcov_dump() to your source code. For Stockfish, best place seems to be uci.cpp at the end of the bench function.

But first, you have to announce the function at the bottom of uci.cpp (maybe after the last include command).

Code: Select all

#include "syzygy/tbprobe.h"

extern "C" void __gcov_dump();
Then add the function at the end of the bench function in uci.cpp.

Code: Select all

cerr << "\n==========================="
     << "\nTotal time (ms) : " << elapsed
     << "\nNodes searched  : " << nodes
     << "\nNodes/second    : " << 1000 * nodes / elapsed << endl;

__gcov_dump();
LittleJoe

Top contribute Forum Engines Maker
Forum Contributions
Points: 14 078,00 
Posts: 327
Joined: 17/10/2020, 22:28
Status: Offline (Active 5 Days, 2 Hours, 20 Minutes ago)
Medals: 2
Topics: 5
Reputation: 506
Has thanked: 349 times
Been thanked: 671 times

Re: Compiling Stockfish with gcc on Termux

Post by LittleJoe »

The function __gcov_dump() has to be called directly after the instrumented benchmark (step 2/4 of profile-build) to make sure that the measured data are written to files (this is a Termux issue). Thus placing __gcov_dump() at the end of the bench call in uci.cpp seemed to me the only logical location. However, I have to admit, that I did not try other locations in the SF code, when I managed to do my first successful pgo-compilation with GCC some time ago. :sm165:
hagtorp
Forum Contributions
Points: 19 796,00 
Posts: 159
Joined: 04/11/2019, 3:15
Status: Offline (Active 7 Months, 19 Hours, 59 Minutes ago)
Topics: 3
Reputation: 30
Has thanked: 9 times
Been thanked: 24 times

Re: Compiling Stockfish with gcc on Termux

Post by hagtorp »

Hi there, long time no see. Does anyone have CCTools packages? The site from where it all swayed does not work, but I do not have a backup.
Post Reply

Return to “Programming, Technical Discussions, Chess related questions etc.”