How to compile xmr-stak (2.10) under CentOS 7 for CPU mining cryptocurrencies in September 2019

A time to refresh our old article on how to compile xmr-stak for CPU mining with the new version and this time a new GNU GCC version (version 8.3, the last article we used 7.x – How to compile xmr-stak (2.4.5) under CentOS 7 for CPU mining cryptocurrencies). Always use the latest available GNU GCC packages because the latest version of GNU GCC could add some optimizations to the binary compiled code and you may have a CPU miner with better performance!
Thanks to xmr-stak we can have one application capable of mining many different cryptocurrencies based on different algorithms. XMR-STAK is GPU and CPU miner and here we present only the CPU ability under CentOS 7 using our AMD Threadripper 1950X.
The software in this article:

  • CentOS 7 – CentOS Linux release 7.6.1810 (Core)
  • GNU GCC – gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)
  • XMR-STAK – 2.10.7

As said many times working with crypto-currency it is mandatory to do the things yourself – do not trust any binary made by someone on the Internet. It is easy to build your miner yourself with the code from the official repository!

So here are the steps to build the XMR-STAK for CPU mining:

STEP 1) Update your system and install the following dependencies

Always start with update command and then install the dependencies in order first install all the new repositories and then the dependency binaries.

sudo yum update -y
sudo yum install -y centos-release-scl epel-release
sudo yum install -y cmake3 devtoolset-8-gcc* hwloc-devel libmicrohttpd-devel openssl openssl-devel make git screen wget

We are going to use GNU GCC 8 to build the XMR-STAK. More on the subject of how to install GNU GCC 8 and what is “devtoolset” here – How to install GNU GCC 8 on CentOS 7.

STEP 2) Compile the mining program xmr-stak

Before we used git to pull from code from the GitHub master branch, but it rear situation you might have problems with it, so this time we are going to use a stable release, just go the official XMR-STAK page on GitHub and copy the link of the latest stable release after clicking on tab “Release” (and if you want to see more you may click on “Tags” in addition – https://github.com/fireice-uk/xmr-stak/tags). At present, the latest release is 2.10.7 with link to the source – https://github.com/fireice-uk/xmr-stak/archive/2.10.7.tar.gz
We have included all the output (adding the couple of ls commands to show what to expect) for completeness of the build process and because the output is not so big.

[myuser@localhost ~]$ scl enable devtoolset-8 bash
[myuser@localhost ~]$ wget https://github.com/fireice-uk/xmr-stak/archive/2.10.7.tar.gz
[myuser@localhost ~]$ tar xf 2.10.7.tar.gz 
[myuser@localhost ~]$ cd xmr-stak-2.10.7/
[myuser@localhost xmr-stak-2.10.7]$ ls -al
total 100
drwxrwxr-x.  7 myuser myuser  4096 Jul 31 15:19 .
drwx------.  3 myuser myuser   106 Sep  5 19:12 ..
-rw-rw-r--.  1 myuser myuser  1249 Jul 31 15:19 .appveyor.yml
drwxrwxr-x.  2 myuser myuser    27 Jul 31 15:19 CI
-rw-rw-r--.  1 myuser myuser   391 Jul 31 15:19 .clang-format
-rw-rw-r--.  1 myuser myuser 24397 Jul 31 15:19 CMakeLists.txt
-rw-rw-r--.  1 myuser myuser   234 Jul 31 15:19 CONTRIBUTING.md
drwxrwxr-x.  4 myuser myuser   125 Jul 31 15:19 doc
-rw-rw-r--.  1 myuser myuser   880 Jul 31 15:19 Dockerfile
-rw-rw-r--.  1 myuser myuser    33 Jul 31 15:19 .gitattributes
drwxrwxr-x.  3 myuser myuser    60 Jul 31 15:19 .github
-rw-rw-r--.  1 myuser myuser   351 Jul 31 15:19 .gitignore
-rw-rw-r--.  1 myuser myuser 32423 Jul 31 15:19 LICENSE
-rw-rw-r--.  1 myuser myuser  4687 Jul 31 15:19 README.md
drwxrwxr-x.  3 myuser myuser    35 Jul 31 15:19 scripts
-rw-rw-r--.  1 myuser myuser  1137 Jul 31 15:19 THIRD-PARTY-LICENSES
-rw-rw-r--.  1 myuser myuser  3104 Jul 31 15:19 .travis.yml
drwxrwxr-x. 10 myuser myuser   264 Jul 31 15:19 xmrstak
[myuser@localhost xmr-stak-2.10.7]$ mkdir build
[myuser@localhost xmr-stak-2.10.7]$ cd build/
[myuser@localhost build]$ export CFLAGS="-O2 -march=native -msse3 -fomit-frame-pointer -pipe"
[myuser@localhost build]$ export CHOST="x86_64-pc-linux-gnu"
[myuser@localhost build]$ export CXXFLAGS="${CFLAGS}"
[myuser@localhost build]$ export LDFLAGS="-Wl,-O1"
[myuser@localhost build]$ cmake3 .. -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF
-- The C compiler identification is GNU 8.3.1
-- The CXX compiler identification is GNU 8.3.1
-- Check for working C compiler: /opt/rh/devtoolset-8/root/usr/bin/cc
-- Check for working C compiler: /opt/rh/devtoolset-8/root/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /opt/rh/devtoolset-8/root/usr/bin/c++
-- Check for working CXX compiler: /opt/rh/devtoolset-8/root/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found OpenSSL: /usr/lib64/libcrypto.so (found version "1.0.2k")  
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-- The ASM compiler identification is GNU
-- Found assembler: /opt/rh/devtoolset-8/root/usr/bin/cc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/myuser/xmr-stak-2.10.7/build
[myuser@localhost build]$ make -j 16
Scanning dependencies of target xmr-stak-asm
[  3%] Building ASM object CMakeFiles/xmr-stak-asm.dir/xmrstak/backend/cpu/crypto/asm/cryptonight_v8_main_loop.S.o
[  6%] Building ASM object CMakeFiles/xmr-stak-asm.dir/xmrstak/backend/cpu/crypto/asm/cnR/CryptonightR_template.S.o
[  9%] Linking C static library bin/libxmr-stak-asm.a
[  9%] Built target xmr-stak-asm
Scanning dependencies of target xmr-stak-c
[ 12%] Building C object CMakeFiles/xmr-stak-c.dir/xmrstak/backend/cpu/crypto/c_blake256.c.o
[ 15%] Building C object CMakeFiles/xmr-stak-c.dir/xmrstak/backend/cpu/crypto/c_jh.c.o
[ 18%] Building C object CMakeFiles/xmr-stak-c.dir/xmrstak/backend/cpu/crypto/c_keccak.c.o
[ 24%] Building C object CMakeFiles/xmr-stak-c.dir/xmrstak/backend/cpu/crypto/c_skein.c.o
[ 24%] Building C object CMakeFiles/xmr-stak-c.dir/xmrstak/backend/cpu/crypto/c_groestl.c.o
[ 27%] Linking C static library bin/libxmr-stak-c.a
[ 27%] Built target xmr-stak-c
Scanning dependencies of target xmr-stak-backend
[ 30%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/cpu/crypto/cn_gpu_avx.cpp.o
[ 33%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/backendConnector.cpp.o
[ 42%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/cpu/crypto/CryptonightR_gen.cpp.o
[ 42%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/cpu/cpuType.cpp.o
[ 42%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/cpu/minethd.cpp.o
[ 48%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/cpu/hwlocMemory.cpp.o
[ 54%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/jconf.cpp.o
[ 54%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/cpu/jconf.cpp.o
[ 54%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/cpu/crypto/cryptonight_common.cpp.o
[ 57%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/cpu/crypto/cn_gpu_ssse3.cpp.o
[ 63%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/http/httpd.cpp.o
[ 63%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/globalStates.cpp.o
[ 66%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/http/webdesign.cpp.o
[ 69%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/misc/console.cpp.o
[ 75%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/misc/telemetry.cpp.o
[ 75%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/misc/executor.cpp.o
[ 78%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/misc/uac.cpp.o
[ 81%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/misc/utility.cpp.o
[ 84%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/net/jpsock.cpp.o
[ 87%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/net/socket.cpp.o
[ 90%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/version.cpp.o
[ 93%] Linking CXX static library bin/libxmr-stak-backend.a
[ 93%] Built target xmr-stak-backend
Scanning dependencies of target xmr-stak
[ 96%] Building CXX object CMakeFiles/xmr-stak.dir/xmrstak/cli/cli-miner.cpp.o
[100%] Linking CXX executable bin/xmr-stak
[100%] Built target xmr-stak
[myuser@localhost build]$ ls -al
total 72
drwxrwxr-x. 4 myuser myuser   100 Sep  5 19:13 .
drwxrwxr-x. 8 myuser myuser  4096 Sep  5 19:12 ..
drwxrwxr-x. 2 myuser myuser    99 Sep  5 19:13 bin
-rw-rw-r--. 1 myuser myuser 19768 Sep  5 19:13 CMakeCache.txt
drwxrwxr-x. 8 myuser myuser  4096 Sep  5 19:13 CMakeFiles
-rw-rw-r--. 1 myuser myuser  1687 Sep  5 19:13 cmake_install.cmake
-rw-rw-r--. 1 myuser myuser 39596 Sep  5 19:13 Makefile
[myuser@localhost build]$ cd bin
[myuser@localhost bin]$ ls -al
total 4124
drwxrwxr-x. 2 myuser myuser      99 Sep  5 19:13 .
drwxrwxr-x. 4 myuser myuser     100 Sep  5 19:13 ..
-rw-rw-r--. 1 myuser myuser   58488 Sep  5 19:13 libxmr-stak-asm.a
-rw-rw-r--. 1 myuser myuser 2500016 Sep  5 19:13 libxmr-stak-backend.a
-rw-rw-r--. 1 myuser myuser   54382 Sep  5 19:13 libxmr-stak-c.a
-rwxrwxr-x. 1 myuser myuser 1598072 Sep  5 19:13 xmr-stak

Execute the program to see if everything is OK. In the help output you should see all supported crypto algorithms:

[myuser@localhost bin]$ ./xmr-stak --help
Usage: xmr-stak [OPTION]...
 
  -h, --help                 show this help
  -v, --version              show version number
  -V, --version-long         show long version number
  -c, --config FILE          common miner configuration file
  -C, --poolconf FILE        pool configuration file
  --benchmark BLOCKVERSION   ONLY do a benchmark and exit
  --benchwait WAIT_SEC             ... benchmark wait time
  --benchwork WORK_SEC             ... benchmark work time
  --noCPU                    disable the CPU miner backend
  --cpu FILE                 CPU backend miner config file
  --log FILE                 miner output file
  --h-print-time SEC         interval for printing hashrate, in seconds
  -i --httpd HTTP_PORT       HTTP interface port
 
The following options can be used for automatic start without a guided config,
If config exists then this pool will be top priority.
  -o, --url URL              pool url and port, e.g. pool.usxmrpool.com:3333
  -O, --tls-url URL          TLS pool url and port, e.g. pool.usxmrpool.com:10443
  -u, --user USERNAME        pool user name or wallet address
  -r, --rigid RIGID          rig identifier for pool-side statistics (needs pool support)
  -p, --pass PASSWD          pool password, in the most cases x or empty ""
  --use-nicehash             the pool should run in nicehash mode
  --currency NAME            currency to mine

Supported coin options: 
        - aeon7
        - bbscoin
        - bittube
        - cryptonight
        - cryptonight_bittube2
        - cryptonight_masari
        - cryptonight_haven
        - cryptonight_heavy
        - cryptonight_lite
        - cryptonight_lite_v7
        - cryptonight_lite_v7_xor
        - cryptonight_r
        - cryptonight_superfast
        - cryptonight_turtle
        - cryptonight_v7
        - cryptonight_v8
        - cryptonight_v8_double
        - cryptonight_v8_half
        - cryptonight_v8_reversewaltz
        - cryptonight_v8_zelerius
        - cryptonight_v7_stellite
        - cryptonight_gpu
        - cryptonight_conceal
        - graft
        - haven
        - lethean
        - masari
        - monero
        - qrl
        - ryo
        - torque
        - plenteum
        - zelerius

Version: xmr-stak 2.10.7 fd19a5d03
Brought to by fireice_uk and psychocrypt under GPLv3.

Additional information

For better performance start XMR-STAK as root user and set first before executing xmr-stak binary file:

sudo sysctl -w vm.nr_hugepages=128

Monero mining

XMR-STAK 2.10.7 (compiled with GNU GCC 8.3.1) on our Threadripper 1950X is capable of around 1200 hashes per second for monero coin:

-----------------------------------------------------------------
[2019-09-05 19:46:13] : CPU: Share accepted. Pool: xmr-eu.dwarfpool.com:8005
[2019-09-05 19:46:25] : CPU: Share accepted. Pool: xmr-eu.dwarfpool.com:8005
[2019-09-05 19:46:37] : CPU: Share accepted. Pool: xmr-eu.dwarfpool.com:8005
[2019-09-05 19:46:45] : CPU: Share accepted. Pool: xmr-eu.dwarfpool.com:8005
[2019-09-05 19:47:00] : CPU: Share accepted. Pool: xmr-eu.dwarfpool.com:8005
[2019-09-05 19:47:16] : CPU: Share accepted. Pool: xmr-eu.dwarfpool.com:8005
[2019-09-05 19:47:19] : CPU: Share accepted. Pool: xmr-eu.dwarfpool.com:8005
[2019-09-05 19:47:36] : CPU: Share accepted. Pool: xmr-eu.dwarfpool.com:8005
HASHRATE REPORT - CPU
| ID |    10s |    60s |    15m | ID |    10s |    60s |    15m |
|  0 |   67.8 |   67.6 |   (na) |  1 |   68.0 |   68.5 |   (na) |
|  2 |   76.0 |   76.0 |   (na) |  3 |   76.0 |   76.0 |   (na) |
|  4 |   76.4 |   76.4 |   (na) |  5 |   68.3 |   68.3 |   (na) |
|  6 |   76.4 |   76.4 |   (na) |  7 |   76.4 |   76.4 |   (na) |
|  8 |   76.5 |   76.4 |   (na) |  9 |   76.5 |   76.5 |   (na) |
| 10 |   76.5 |   76.5 |   (na) | 11 |   76.4 |   76.5 |   (na) |
| 12 |   68.3 |   68.3 |   (na) | 13 |   76.4 |   76.3 |   (na) |
| 14 |   76.4 |   76.4 |   (na) | 15 |   76.4 |   76.4 |   (na) |
Totals (CPU):  1188.4 1188.7    0.0 H/s
-----------------------------------------------------------------
Totals (ALL):   1188.4 1188.7    0.0 H/s
Highest:  1216.8 H/s
-----------------------------------------------------------------
RESULT REPORT
Currency         : monero
Difficulty       : 20000
Good results     : 27 / 27 (100.0 %)
Avg result time  : 16.0 sec
Pool-side hashes : 540000

Top 10 best results found:
|  0 |          1906006 |  1 |           842739 |
|  2 |           652994 |  3 |           277032 |
|  4 |           113851 |  5 |            96295 |
|  6 |            79556 |  7 |            74418 |
|  8 |            65693 |  9 |            59495 |

Error details:
Yay! No errors.

Leave a Reply

Your email address will not be published. Required fields are marked *