Compiling Stockfish with gcc on Termux

Moderators: Elijah, Igbo, timetraveller

Archimedes

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

Re: Compiling Stockfish with gcc on Termux

Post by Archimedes »

kramnik wrote: 14/04/2023, 11:29 So how can I use it to compile BrainLearn?
Archimedes wrote: 14/04/2023, 9:54
kramnik wrote: 10/04/2023, 11:37 I searched on Google about "mm_malloc.h: No such file or directory" but I didn't found anything relevant. Looks like this header is inside the libgcc-*-dev that is not in the Termux repositories.
Should be present in the include directory of the Clang compiler.
Something seems to be wrong with your clang installation. The file should be in the ../usr/lib/clang/16/include directory (if Clang 16 is installed). Which version of the Clang compiler are you using? Were there any error messages during the last update ("pkg upgrade")? If so, follow the instructions to fix them.
kramnik

Top contribute Forum
Forum Contributions
Points: 40 305,00 
Posts: 1924
Joined: 04/11/2019, 14:45
Status: Offline (Active 3 Months, 6 Days, 17 Hours, 8 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 »

Uh, I see mow: I have to use clang to compile it and not gcc.
Archimedes wrote: 15/04/2023, 8:34
kramnik wrote: 14/04/2023, 11:29 So how can I use it to compile BrainLearn?
Archimedes wrote: 14/04/2023, 9:54
Should be present in the include directory of the Clang compiler.
Something seems to be wrong with your clang installation. The file should be in the ../usr/lib/clang/16/include directory (if Clang 16 is installed). Which version of the Clang compiler are you using? Were there any error messages during the last update ("pkg upgrade")? If so, follow the instructions to fix them.
Archimedes

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

Re: Compiling Stockfish with gcc on Termux

Post by Archimedes »

That was my mistake. Sorry. GCC is already the right choice here.

By the way, you have to make the same quick and dirty changes for the makefile of BrainLearn as for Stockfish. As an alternative, just use the makefile of BrainLearn in the CECSA script.

Code: Select all

make net
make profile-build
kramnik

Top contribute Forum
Forum Contributions
Points: 40 305,00 
Posts: 1924
Joined: 04/11/2019, 14:45
Status: Offline (Active 3 Months, 6 Days, 17 Hours, 8 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 just looked through it and I did the changed already.

Here's the whole thing:

https://pastebin.com/L03mmvrK

Lines:
395
396
538
581

At this point we have two ways:

1. I can just use your cecsa Makefile
2. You can tell me what are the other parts of the original Makefile to change.

I memorised long ago the changes I had to make for Stockfish, I guess the second way would be the easier one instead of copying any time the Makefile. I find the whole Termux thing extremely cool: very practical, easy to use for those who know the basic of programming.

And Archimedes: my compliments for being so skilled in this environment. ok-ok [thank_you
Archimedes wrote: 15/04/2023, 11:27 That was my mistake. Sorry. GCC is already the right choice here.

By the way, you have to make the same quick and dirty changes for the makefile of BrainLearn as for Stockfish. As an alternative, just use the makefile of BrainLearn in the CECSA script.

Code: Select all

make net
make profile-build
Archimedes

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

Re: Compiling Stockfish with gcc on Termux

Post by Archimedes »

I'm glad when I don't have to fiddle with these makefiles anymore. Just use my makefile.
kramnik

Top contribute Forum
Forum Contributions
Points: 40 305,00 
Posts: 1924
Joined: 04/11/2019, 14:45
Status: Offline (Active 3 Months, 6 Days, 17 Hours, 8 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 used your Makefile and I still got the error. :???:

Code: Select all

~/.../BrainLearn-23/src $ make profile-build
g++ -std=c++17 -O3 -flto -fexceptions -frtti -march=native -flto-partition=one -fno-gcse  -fprofile-generate -DNDEBUG -DIS_64BIT -DNNUE_EMBEDDING_OFF -DUSE_LIVEBOOK -DUSE_NEON=8 -DUSE_POPCNT -DUSE_PTHREADS -D__BIONIC_VERSIONER -Wfatal-errors -Wall -Wextra *.cpp mcts/*.cpp nnue/*.cpp nnue/features/*.cpp syzygy/*.cpp -static-libstdc++ -Wl,-Bstatic -L/data/data/com.termux/files/usr/opt/ndk-multilib/aarch64-linux-android/lib -ldl -L/data/data/com.termux/files/usr/lib -lcrypto -lcurl -lnghttp2 -lssh2 -lssl -lz -Wl,-Bdynamic -lgcov -o BrainLearn
In file included from position.h:31,
                 from benchmark.cpp:26:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from bitboard.cpp:23:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from position.h:31,
                 from endgame.h:28,
                 from endgame.cpp:22:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from position.h:31,
                 from endgame.h:28,
                 from material.h:22,
                 from evaluate.cpp:32:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from learn.cpp:4:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from position.h:31,
                 from endgame.h:28,
                 from main.cpp:22:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from position.h:31,
                 from endgame.h:28,
                 from material.h:22,
                 from material.cpp:22:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from misc.cpp:67:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from position.h:31,
                 from movegen.cpp:22:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from position.h:31,
                 from movepick.h:27,
                 from movepick.cpp:22:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from pawns.h:22,
                 from pawns.cpp:23:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from position.h:31,
                 from polybook.h:23,
                 from polybook.cpp:19:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from position.cpp:28:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from position.h:31,
                 from polybook.h:23,
                 from search.cpp:26:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from search.h:24,
                 from thread.cpp:23:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from search.h:24,
                 from timeman.cpp:23:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from tt.cpp:24:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from tune.cpp:24:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from position.h:31,
                 from uci.cpp:28:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from ucioption.cpp:25:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from mcts/montecarlo.cpp:28:
mcts/../misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from nnue/../position.h:31,
                 from nnue/evaluate_nnue.cpp:29:
nnue/../misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from nnue/features/../nnue_common.h:27,
                 from nnue/features/half_ka_v2_hm.h:24,
                 from nnue/features/half_ka_v2_hm.cpp:21:
nnue/features/../../misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from syzygy/../position.h:31,
                 from syzygy/tbprobe.cpp:34:
syzygy/../misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:32: profile-build] Error 1
~/.../BrainLearn-23/src $
Archimedes wrote: 15/04/2023, 21:05 I'm glad when I don't have to fiddle with these makefiles anymore. Just use my makefile.
Archimedes

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

Re: Compiling Stockfish with gcc on Termux

Post by Archimedes »

There is something wrong with your environment. Which version of GCC are you using? Did you install it yourself? Ever thought about reinstalling Termux? Use my script cecsa.sh and you will get a working compile environment (Clang, GCC and Android NDK). Just follow the instructions at the beginning of the script. It's only a matter of a few minutes.
kramnik

Top contribute Forum
Forum Contributions
Points: 40 305,00 
Posts: 1924
Joined: 04/11/2019, 14:45
Status: Offline (Active 3 Months, 6 Days, 17 Hours, 8 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 reinstalled the whole Termux in order to use your cecsa script! And the gcc is the one provided by it:

Code: Select all

~ $ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/data/data/com.termux/files/cctools-toolchain/lib/gcc/aarch64-linux-android/10/lto-wrapper
Target: aarch64-linux-android
Configured with: /Storage/nfs/cctools/cctools-repo/tmp-pie/arm64-repo/src/gcc-10.3.0/configure --target=aarch64-linux-android --host=aarch64-linux-android --prefix=/data/data/com.termux/files/cctools-toolchain --libexecdir=/data/data/com.termux/files/cctools-toolchain/lib --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++,fortran,objc,obj-c++ --enable-bionic-libs --enable-libatomic-ifuncs=no --enable-cloog-backend=isl --disable-libssp --enable-threads --disable-libmudflap --disable-sjlj-exceptions --disable-shared --disable-tls --disable-libitm --enable-initfini-array --disable-nls --disable-bootstrap --disable-libquadmath --enable-plugins --enable-libgomp --disable-libsanitizer --enable-graphite=yes --with-gcc-major-version-only --program-suffix=-10 --enable-objc-gc=auto --enable-eh-frame-hdr-for-static --enable-target-optspace --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-fix-cortex-a53-835769 --enable-default-pie
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.3.0 (GCC)
Archimedes wrote: 19/04/2023, 14:31 There is something wrong with your environment. Which version of GCC are you using? Did you install it yourself? Ever thought about reinstalling Termux? Use my script cecsa.sh and you will get a working compile environment (Clang, GCC and Android NDK). Just follow the instructions at the beginning of the script. It's only a matter of a few minutes.
Archimedes

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

Re: Compiling Stockfish with gcc on Termux

Post by Archimedes »

kramnik wrote: 25/04/2023, 23:54 I reinstalled the whole Termux in order to use your cecsa script! And the gcc is the one provided by it:

Code: Select all

~ $ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/data/data/com.termux/files/cctools-toolchain/lib/gcc/aarch64-linux-android/10/lto-wrapper
Target: aarch64-linux-android
Configured with: /Storage/nfs/cctools/cctools-repo/tmp-pie/arm64-repo/src/gcc-10.3.0/configure --target=aarch64-linux-android --host=aarch64-linux-android --prefix=/data/data/com.termux/files/cctools-toolchain --libexecdir=/data/data/com.termux/files/cctools-toolchain/lib --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++,fortran,objc,obj-c++ --enable-bionic-libs --enable-libatomic-ifuncs=no --enable-cloog-backend=isl --disable-libssp --enable-threads --disable-libmudflap --disable-sjlj-exceptions --disable-shared --disable-tls --disable-libitm --enable-initfini-array --disable-nls --disable-bootstrap --disable-libquadmath --enable-plugins --enable-libgomp --disable-libsanitizer --enable-graphite=yes --with-gcc-major-version-only --program-suffix=-10 --enable-objc-gc=auto --enable-eh-frame-hdr-for-static --enable-target-optspace --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-fix-cortex-a53-835769 --enable-default-pie
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.3.0 (GCC)
By default, GCC version 11 will be installed (recommended). The GCC compiler from CCTools is only installed if you change the following in the script (cecsa.sh):

Code: Select all

CECSA_COMPILER_GCC_COMMUNITY_ENABLED=false
CECSA supports both variants of the GCC compiler.
kramnik

Top contribute Forum
Forum Contributions
Points: 40 305,00 
Posts: 1924
Joined: 04/11/2019, 14:45
Status: Offline (Active 3 Months, 6 Days, 17 Hours, 8 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 »

Archimedes wrote: 26/04/2023, 10:09By default, GCC version 11 will be installed (recommended). The GCC compiler from CCTools is only installed if you change the following in the script (cecsa.sh):

Code: Select all

CECSA_COMPILER_GCC_COMMUNITY_ENABLED=false
CECSA supports both variants of the GCC compiler.
This is the cecsa.sh I used:

Code: Select all

#!/data/data/com.termux/files/usr/bin/bash

CECSA_COMPILER_GCC_COMMUNITY_ENABLED=true
CECSA_COMPILER_GCC_COMMUNITY_VERSION=11

termux-change-repo

# Upgrade existing packages
pkg upgrade

# Tools and libraries
pkg install git gnupg make mc ndk-multilib wget zip
pkg install libcurl-static libnghttp2-static libssh2-static openssl-static zlib-static

# GCC
  mkdir -p ../usr/etc/apt/sources.list.d
  wget -O - https://cctools.info/public.key | apt-key add -
  echo 'deb https://cctools.info termux cctools' > ../usr/etc/apt/sources.list.d/cctools.list
  apt update --allow-insecure-repositories
  pkg install gcc-cctools ndk-sysroot-cctools-api-21-aarch64
  echo 'export PATH=/data/data/com.termux/files/cctools-toolchain/bin:$PATH' > .bashrc
  echo '# deb https://cctools.info termux cctools' > ../usr/etc/apt/sources.list.d/cctools.list

# CECSA
if [ -f /storage/emulated/0/Download/cecsa*.tar.gz ]; then
  echo Unpacking CECSA...
  tar -xf /storage/emulated/0/Download/cecsa*.tar.gz
  if [ "${CECSA_COMPILER_GCC_COMMUNITY_ENABLED,,}" == "false" ]; then
    sed -i 's/CECSA_COMPILER_GCC_COMMUNITY=true/CECSA_COMPILER_GCC_COMMUNITY=false'/ cecsa/start.sh
  fi
fi

# CETSA
if [ -f /storage/emulated/0/Download/cetsa*.tar.gz ]; then
  echo Unpacking CETSA...
  tar -xf /storage/emulated/0/Download/cetsa*.tar.gz
fi

mkdir -p sdcard
ln -s /storage/emulated/0/Download sdcard/Download

echo
echo Installation completed.
echo Type \'logout\' or \'exit\' and start Termux again.
Archimedes

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

Re: Compiling Stockfish with gcc on Termux

Post by Archimedes »

kramnik wrote: 26/04/2023, 12:32
Archimedes wrote: 26/04/2023, 10:09By default, GCC version 11 will be installed (recommended). The GCC compiler from CCTools is only installed if you change the following in the script (cecsa.sh):

Code: Select all

CECSA_COMPILER_GCC_COMMUNITY_ENABLED=false
CECSA supports both variants of the GCC compiler.
This is the cecsa.sh I used:

Code: Select all

#!/data/data/com.termux/files/usr/bin/bash

CECSA_COMPILER_GCC_COMMUNITY_ENABLED=true
CECSA_COMPILER_GCC_COMMUNITY_VERSION=11

termux-change-repo

# Upgrade existing packages
pkg upgrade

# Tools and libraries
pkg install git gnupg make mc ndk-multilib wget zip
pkg install libcurl-static libnghttp2-static libssh2-static openssl-static zlib-static

# GCC
  mkdir -p ../usr/etc/apt/sources.list.d
  wget -O - https://cctools.info/public.key | apt-key add -
  echo 'deb https://cctools.info termux cctools' > ../usr/etc/apt/sources.list.d/cctools.list
  apt update --allow-insecure-repositories
  pkg install gcc-cctools ndk-sysroot-cctools-api-21-aarch64
  echo 'export PATH=/data/data/com.termux/files/cctools-toolchain/bin:$PATH' > .bashrc
  echo '# deb https://cctools.info termux cctools' > ../usr/etc/apt/sources.list.d/cctools.list

# CECSA
if [ -f /storage/emulated/0/Download/cecsa*.tar.gz ]; then
  echo Unpacking CECSA...
  tar -xf /storage/emulated/0/Download/cecsa*.tar.gz
  if [ "${CECSA_COMPILER_GCC_COMMUNITY_ENABLED,,}" == "false" ]; then
    sed -i 's/CECSA_COMPILER_GCC_COMMUNITY=true/CECSA_COMPILER_GCC_COMMUNITY=false'/ cecsa/start.sh
  fi
fi

# CETSA
if [ -f /storage/emulated/0/Download/cetsa*.tar.gz ]; then
  echo Unpacking CETSA...
  tar -xf /storage/emulated/0/Download/cetsa*.tar.gz
fi

mkdir -p sdcard
ln -s /storage/emulated/0/Download sdcard/Download

echo
echo Installation completed.
echo Type \'logout\' or \'exit\' and start Termux again.
This is not the current script. And that's certainly not how I published it on SourceForge. wink

The current script can be downloaded here:
https://sourceforge.net/projects/chess-tools-for-android/files/cecsa.sh/download

The best thing will be to reinstall Termux.
Last edited by Archimedes on 26/04/2023, 12:48, edited 1 time in total.
kramnik

Top contribute Forum
Forum Contributions
Points: 40 305,00 
Posts: 1924
Joined: 04/11/2019, 14:45
Status: Offline (Active 3 Months, 6 Days, 17 Hours, 8 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 »

Ok, I have reinstalled Termux from scratch and then used your intact cecsa.sh script, the error persists:

Code: Select all

~/BrainLearn-23/src $ make profile-build
g++ -std=c++17 -O3 -flto -fexceptions -frtti -march=native -flto-partition=one -fno-gcse  -fprofile-generate -DNDEBUG -DIS_64BIT -DNNUE_EMBEDDING_OFF -DUSE_LIVEBOOK -DUSE_NEON=8 -DUSE_POPCNT -DUSE_PTHREADS -D__BIONIC_VERSIONER -Wfatal-errors -Wall -Wextra *.cpp mcts/*.cpp nnue/*.cpp nnue/features/*.cpp syzygy/*.cpp -static-libstdc++ -Wl,-Bstatic -L/data/data/com.termux/files/usr/opt/ndk-multilib/aarch64-linux-android/lib -ldl -L/data/data/com.termux/files/usr/lib -lcrypto -lcurl -lnghttp2 -lssh2 -lssl -lz -Wl,-Bdynamic -lgcov -o BrainLearn                                             In file included from position.h:31,
                 from benchmark.cpp:26:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.                                    In file included from bitboard.cpp:23:
misc.h:32:10: fatal error: mm_malloc.h: No such file or directory
   32 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
GCC version:

Code: Select all

~/BrainLearn-23/src $ gcc -v
Reading specs from /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/11.1.0/specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/data/data/com.termux/files/usr/libexec/gcc/aarch64-linux-android/11.1.0/lto-wrapper
Target: aarch64-linux-android
Configured with: /home/builder/.termux-build/gcc-11/src/configure --disable-dependency-tracking --prefix=/data/data/com.termux/files/usr --libdir=/data/data/com.termux/files/usr/lib --sbindir=/data/data/com.termux/files/usr/bin --disable-rpath --disable-rpath-hack --host=aarch64-linux-android --enable-languages=c,c++,fortran,jit,objc,ada --with-system-zlib --disable-multilib --target=aarch64-linux-android --with-libgfortran --enable-static --with-gmp=/data/data/com.termux/files/usr --with-mpfr=/data/data/com.termux/files/usr --with-mpc=/data/data/com.termux/files/usr --with-isl-include=/data/data/com.termux/files/usr/include --with-isl-lib=/data/data/com.termux/files/usr/lib --disable-isl-version-check --disable-libssp --with-stage1-ldflags=-specs=/home/builder/.termux-build/gcc-11/tmp/specs --disable-tls --enable-lto --enable-gold=yes --enable-libatomic --program-suffix=-11 --enable-libbacktrace --enable-host-shared --enable-host-libquadmath --enable-libatomic-ifuncs=no --enable-default-pie ac_cv_c_bigendian=no --with-libatomic --disable-libstdcxx --enable-version-specific-runtime-libs --enable-eh-frame-hdr-for-static --disable-libmpx -with-gxx-include-dir=/data/data/com.termux/files/usr/include/c++/v1 --with-arch=armv8-a --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419 --enable-libssp --disable-nls --enable-shared --enable-static --libexecdir=/data/data/com.termux/files/usr/libexec
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (GCC)
Archimedes wrote: 26/04/2023, 12:44
kramnik wrote: 26/04/2023, 12:32
Archimedes wrote: 26/04/2023, 10:09By default, GCC version 11 will be installed (recommended). The GCC compiler from CCTools is only installed if you change the following in the script (cecsa.sh):

Code: Select all

CECSA_COMPILER_GCC_COMMUNITY_ENABLED=false
CECSA supports both variants of the GCC compiler.
This is the cecsa.sh I used:

Code: Select all

#!/data/data/com.termux/files/usr/bin/bash

CECSA_COMPILER_GCC_COMMUNITY_ENABLED=true
CECSA_COMPILER_GCC_COMMUNITY_VERSION=11

termux-change-repo

# Upgrade existing packages
pkg upgrade

# Tools and libraries
pkg install git gnupg make mc ndk-multilib wget zip
pkg install libcurl-static libnghttp2-static libssh2-static openssl-static zlib-static

# GCC
  mkdir -p ../usr/etc/apt/sources.list.d
  wget -O - https://cctools.info/public.key | apt-key add -
  echo 'deb https://cctools.info termux cctools' > ../usr/etc/apt/sources.list.d/cctools.list
  apt update --allow-insecure-repositories
  pkg install gcc-cctools ndk-sysroot-cctools-api-21-aarch64
  echo 'export PATH=/data/data/com.termux/files/cctools-toolchain/bin:$PATH' > .bashrc
  echo '# deb https://cctools.info termux cctools' > ../usr/etc/apt/sources.list.d/cctools.list

# CECSA
if [ -f /storage/emulated/0/Download/cecsa*.tar.gz ]; then
  echo Unpacking CECSA...
  tar -xf /storage/emulated/0/Download/cecsa*.tar.gz
  if [ "${CECSA_COMPILER_GCC_COMMUNITY_ENABLED,,}" == "false" ]; then
    sed -i 's/CECSA_COMPILER_GCC_COMMUNITY=true/CECSA_COMPILER_GCC_COMMUNITY=false'/ cecsa/start.sh
  fi
fi

# CETSA
if [ -f /storage/emulated/0/Download/cetsa*.tar.gz ]; then
  echo Unpacking CETSA...
  tar -xf /storage/emulated/0/Download/cetsa*.tar.gz
fi

mkdir -p sdcard
ln -s /storage/emulated/0/Download sdcard/Download

echo
echo Installation completed.
echo Type \'logout\' or \'exit\' and start Termux again.
This is not the current script. And that's certainly not how I published it on SourceForge. wink

The current script can be downloaded here:
https://sourceforge.net/projects/chess-tools-for-android/files/cecsa.sh/download

The best thing will be to reinstall Termux.
Archimedes

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

Re: Compiling Stockfish with gcc on Termux

Post by Archimedes »

kramnik wrote: 26/04/2023, 13:16 Ok, I have reinstalled Termux from scratch and then used your intact cecsa.sh script, the error persists:
Oh, I missed something and made you work. sorry_1

This way you have at least learned how to rebuild Termux and install all the necessary compilers and libraries using the script "cecsa.sh" in a few minutes. Everything has its deeper meaning. :smile:

You need to make the following changes in the misc.h file:

Before:

Code: Select all

#include <mm_malloc.h>
After:

Code: Select all

// #include <mm_malloc.h>
But this is not the only change you have to make if you want to compile BrainLearn yourself (without the help of CECSA).

Some other changes include:
polybook.cpp:

Code: Select all

// #include <sys/timeb.h>
search.cpp:

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, 6 Days, 17 Hours, 8 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 »

Archimedes wrote: 26/04/2023, 13:59You need to make the following changes in the misc.h file:

Before:

Code: Select all

#include <mm_malloc.h>
After:

Code: Select all

// #include <mm_malloc.h>
But this is not the only change you have to make if you want to compile BrainLearn yourself (without the help of CECSA).

Some other changes include:
polybook.cpp:

Code: Select all

// #include <sys/timeb.h>
search.cpp:

Code: Select all

#include "/data/data/com.termux/files/usr/include/curl/curl.h"
Are we sure that commenting a library out of nowhere is a wise thing to do?... I guess that malloc was placed there for a reason. Too bad amchess is not here anymore, otherwise he could enlighten us...

About this:
Archimedes wrote: 26/04/2023, 13:59 This way you have at least learned how to rebuild Termux and install all the necessary compilers and libraries using the script "cecsa.sh" in a few minutes.
It's kinda trying to teach to a 23 years in service cop how to fire with a gun... Linux was my first system back in '99 amongst the ones still being used. Before - from '87 until '98 - I used KERNAL.
Archimedes

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

Re: Compiling Stockfish with gcc on Termux

Post by Archimedes »

kramnik wrote: 26/04/2023, 19:57 Are we sure that commenting a library out of nowhere is a wise thing to do?... I guess that malloc was placed there for a reason.
Leave the answer to the compiler if you are not sure. :smile:
Post Reply

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