How to compile xmr-stak (2.4.5) under CentOS 7 for CPU mining cryptocurrencies

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, here we present only the CPU ability. Here are the steps you should do to install (in fact install dependencies and compile the miner) and to begin CPU mining:

STEP 1) Update your system and install the following dependencies

Because xmr-stak need a newer version of GNU GCC than the CentOS ships with you must install GNU GCC 5.1 at least. Because the latest versions have better optimizations for the processors we use here GNU GCC 7 from Software Collection repository – more information for this repository here: How to install new gcc and development tools under CentOS 7

[myuser@srv ~]# sudo yum update -y
[myuser@srv ~]# sudo yum install -y centos-release-scl epel-release
[myuser@srv ~]# sudo yum install -y cmake3 devtoolset-7-gcc* hwloc-devel libmicrohttpd-devel openssl openssl-devel make git screen

STEP 2) Compile the mining program xmr-stak

[myuser@srv ~]# scl enable devtoolset-7 bash
[myuser@srv ~]# git clone https://github.com/fireice-uk/xmr-stak.git
Cloning into 'xmr-stak'...
remote: Counting objects: 4926, done.
remote: Total 4926 (delta 0), reused 0 (delta 0), pack-reused 4926
Receiving objects: 100% (4926/4926), 1.45 MiB | 0 bytes/s, done.
Resolving deltas: 100% (3512/3512), done.
[myuser@srv ~]# mkdir xmr-stak/build
[myuser@srv ~]# cd xmr-stak/build
[myuser@srv build]# export CFLAGS="-O2 -march=native -msse3 -fomit-frame-pointer -pipe"
[myuser@srv build]# export CHOST="x86_64-pc-linux-gnu"
[myuser@srv build]# export CXXFLAGS="${CFLAGS}"
[myuser@srv build]# export LDFLAGS="-Wl,-O1"
[myuser@srv build]# cmake3 .. -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF
-- 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") 
-- Configuring done
-- Generating done
-- Build files have been written to: /root/xmr-stak/build
[myuser@srv build]# make -j 8
Scanning dependencies of target xmr-stak-c
[  3%] Building C object CMakeFiles/xmr-stak-c.dir/xmrstak/backend/cpu/crypto/c_jh.c.o
[ 19%] Building C object CMakeFiles/xmr-stak-c.dir/xmrstak/backend/cpu/crypto/c_blake256.c.o
[ 19%] Building C object CMakeFiles/xmr-stak-c.dir/xmrstak/backend/cpu/crypto/c_groestl.c.o
[ 19%] Building C object CMakeFiles/xmr-stak-c.dir/xmrstak/backend/cpu/crypto/c_keccak.c.o
[ 19%] Building C object CMakeFiles/xmr-stak-c.dir/xmrstak/backend/cpu/crypto/c_skein.c.o
[ 23%] Linking C static library bin/libxmr-stak-c.a
[ 23%] Built target xmr-stak-c
Scanning dependencies of target xmr-stak-backend
[ 26%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/version.cpp.o
[ 30%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/cpu/jconf.cpp.o
[ 34%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/jconf.cpp.o
[ 38%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/cpu/minethd.cpp.o
[ 42%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/cpu/hwlocMemory.cpp.o
[ 46%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/backendConnector.cpp.o
[ 50%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/cpu/crypto/cryptonight_common.cpp.o
[ 53%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/backend/globalStates.cpp.o
[ 57%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/http/httpd.cpp.o
[ 61%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/http/webdesign.cpp.o
[ 65%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/misc/console.cpp.o
[ 69%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/misc/executor.cpp.o
[ 73%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/misc/telemetry.cpp.o
[ 76%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/misc/uac.cpp.o
[ 80%] 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
[ 88%] Building CXX object CMakeFiles/xmr-stak-backend.dir/xmrstak/net/socket.cpp.o
[ 92%] Linking CXX static library bin/libxmr-stak-backend.a
[ 92%] 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
[root@srv build]#

Execute the program to see if everything is OK. With the help output you can see how many algorithms are supported as of version 2.4.5 of xmr-stak.

[myuser@srv bin]# cd bin
[myuser@srv 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
  -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
        - croat
        - cryptonight
        - cryptonight_masari
        - cryptonight_haven
        - cryptonight_heavy
        - cryptonight_lite
        - cryptonight_lite_v7
        - cryptonight_lite_v7_xor
        - cryptonight_v7
        - cryptonight_v7_stellite
        - edollar
        - electroneum
        - graft
        - haven
        - intense
        - ipbc
        - karbo
        - masari
        - monero7
        - stellite
        - sumokoin
        - turtlecoin

Version: xmr-stak 2.4.5 b3f79de
Brought to by fireice_uk and psychocrypt under GPLv3.

Electroneum CPU mining with XMR-STAK

Using Cryptonote V7 Variant 1 (aka. “monerov7″/”cryptonight_v7”) algorithm. First run.
Couple of important questions to answer:

  • Please enter the currency that you want to mine: cryptonight_v7
  • Username (wallet address or pool login): etnk111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 – this is your address, put here your real public wallet address, DO NOT PUT THIS FALSE ADDRESS
  • Pool address: pool.etn.spacepools.org:3333 – the pool address to use, we use etn.spacepools.org pool
  • Username (wallet address or pool login): your email address
[myuser@srv bin]# sudo sysctl -w vm.nr_hugepages=128
vm.nr_hugepages = 128
[myuser@srv bin]# ./xmr-stak 
Please enter:
- Do you want to use the HTTP interface?
Unlike the screen display, the browser interface is not affected by the GPU lag.
If you don't want to use it, please enter 0, otherwise enter port number that the miner should listen on
0
Configuration stored in file 'config.txt'
Please enter:
- Please enter the currency that you want to mine: 
        - aeon7
        - bbscoin
        - croat
        - cryptonight
        - cryptonight_masari
        - cryptonight_haven
        - cryptonight_heavy
        - cryptonight_lite
        - cryptonight_lite_v7
        - cryptonight_lite_v7_xor
        - cryptonight_v7
        - cryptonight_v7_stellite
        - edollar
        - electroneum
        - graft
        - haven
        - intense
        - ipbc
        - karbo
        - masari
        - monero7
        - stellite
        - sumokoin
        - turtlecoin

cryptonight_v7
- Pool address: e.g. pool.example.com:3333
pool.etn.spacepools.org:3333
- Username (wallet address or pool login):
etnk111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
- Password (mostly empty or x):
myuser@example.com
- Rig identifier for pool-side statistics (needs pool support). Can be empty:

- Does this pool port support TLS/SSL? Use no if unknown. (y/N)
N
- Do you want to use nicehash on this pool? (y/n)
n
- Do you want to use multiple pools? (y/n)
n
Pool configuration stored in file 'pools.txt'
[2018-06-28 01:30:14] : MEMORY ALLOC FAILED: mlock failed
[2018-06-28 01:30:14] : MEMORY ALLOC FAILED: mlock failed
[2018-06-28 01:30:14] : MEMORY ALLOC FAILED: mlock failed
[2018-06-28 01:30:14] : MEMORY ALLOC FAILED: mlock failed
[2018-06-28 01:30:14] : MEMORY ALLOC FAILED: mlock failed
-------------------------------------------------------------------
xmr-stak 2.4.5 b3f79de

Brought to you by fireice_uk and psychocrypt under GPLv3.
Based on CPU mining code by wolf9466 (heavily optimized by fireice_uk).

Configurable dev donation level is set to 2.0%

You can use following keys to display reports:
'h' - hashrate
'r' - results
'c' - connection
-------------------------------------------------------------------
xmr-stak 2.4.5 b3f79de

Brought to you by fireice_uk and psychocrypt under GPLv3.
Based on CPU mining code by wolf9466 (heavily optimized by fireice_uk).

Configurable dev donation level is set to 2.0%

You can use following keys to display reports:
'h' - hashrate
'r' - results
'c' - connection
-------------------------------------------------------------------
[2018-06-28 01:30:14] : Mining coin: cryptonight_v7
[2018-06-28 01:30:14] : Starting 1x thread, affinity: 0.
[2018-06-28 01:30:14] : hwloc: can't bind memory
[2018-06-28 01:30:14] : Starting 1x thread, affinity: 1.
[2018-06-28 01:30:14] : MEMORY ALLOC FAILED: mlock failed
[2018-06-28 01:30:14] : hwloc: can't bind memory
[2018-06-28 01:30:14] : Starting 1x thread, affinity: 2.
[2018-06-28 01:30:14] : MEMORY ALLOC FAILED: mlock failed
[2018-06-28 01:30:14] : hwloc: can't bind memory
[2018-06-28 01:30:14] : Starting 1x thread, affinity: 3.
[2018-06-28 01:30:14] : MEMORY ALLOC FAILED: mlock failed
[2018-06-28 01:30:14] : hwloc: can't bind memory
[2018-06-28 01:30:14] : Fast-connecting to pool.etn.spacepools.org:3333 pool ...
[2018-06-28 01:30:14] : MEMORY ALLOC FAILED: mlock failed
[2018-06-28 01:30:14] : Pool pool.etn.spacepools.org:3333 connected. Logging in...
[2018-06-28 01:30:14] : Difficulty changed. Now: 50000.
[2018-06-28 01:30:14] : Pool logged in.
[2018-06-28 01:30:35] : Result accepted by the pool.
[2018-06-28 01:30:43] : Difficulty changed. Now: 35714.
[2018-06-28 01:30:43] : New block detected.
[2018-06-28 01:31:13] : Difficulty changed. Now: 25000.
[2018-06-28 01:31:13] : New block detected.
[2018-06-28 01:31:43] : Difficulty changed. Now: 17500.
[2018-06-28 01:31:43] : New block detected.
[2018-06-28 01:32:13] : Difficulty changed. Now: 12250.
[2018-06-28 01:32:13] : New block detected.
HASHRATE REPORT - CPU
| ID |    10s |    60s |    15m | ID |    10s |    60s |    15m |
|  0 |   67.5 |   64.9 |   (na) |  1 |   68.3 |   67.7 |   (na) |
|  2 |   69.1 |   67.9 |   (na) |  3 |   66.4 |   65.3 |   (na) |
Totals (CPU):   271.3  265.8    0.0 H/s
-----------------------------------------------------------------
Totals (ALL):    271.3  265.8    0.0 H/s
Highest:   274.7 H/s
-----------------------------------------------------------------
RESULT REPORT
Difficulty       : 3845
Good results     : 49 / 49 (100.0 %)
Avg result time  : 16.3 sec
Pool-side hashes : 223158

Top 10 best results found:
|  0 |           298785 |  1 |           231734 |
|  2 |           176492 |  3 |            82592 |
|  4 |            50284 |  5 |            49914 |
|  6 |            28493 |  7 |            22570 |
|  8 |            18460 |  9 |            17889 |

Error details:
Yay! No errors.

the processor is “Intel(R) Xeon(R) CPU E3-1231 v3 @ 3.40GHz” and the hash power is 274.7 H/s.

10 thoughts on “How to compile xmr-stak (2.4.5) under CentOS 7 for CPU mining cryptocurrencies”

  1. Hello there
      I compiled xmr-stak on Centos7 through your demo and it works. But when I run it on Centos6, I get the following error. Can you teach me how to be compatible?

    ./xmr-stak: /lib64/libc.so.6: version `GLIBC_2.14′ not found (required by ./xmr-stak)
    ./xmr-stak: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.5′ not found (required by ./xmr-stak)
    ./xmr-stak: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14′ not found (required by ./xmr-stak)
    ./xmr-stak: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.19′ not found (required by ./xmr-stak)
    ./xmr-stak: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15′ not found (required by ./xmr-stak)

  2. Hi,
    you must build the xmr-stak under CentOS 6, you cannot use the binary compiled for CentOS 7 in CentOS 6. Cannot copy the directory from CentOS 7 to CentOS6.
    The steps above are the same if you want to build it for CentOS 6, we’ve tested and they worked as if we were under CentOS 7. So you can just switch to your CentOS 6 and execute the same command above to have a working xmr-stak under CentOS 6.

      1. It will not work, a build under CentOS 6 will work only under CentOS 6 and a build under CentOS 7 will work only under CentOS 7. xmr-stak si dynamically link to the libraries under the system you used to build. There is some static options you can enable with “-DCMAKE_LINK_STATIC=ON -DXMR-STAK_COMPILE=generic -DMICROHTTPD_ENABLE=OFF”, but it still will not make it completely static (it should include only a couple core libs – gcc, glibc), because most of the libraries in linux are dynamic like openssl and so on. And xmr-stak has a good deal of libraries which uses dynamically:
        [root@srv bin]# ldd xmr-stak
        linux-vdso.so.1 => (0x00007ffeaa73c000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f402aa38000)
        libmicrohttpd.so.10 => /usr/lib64/libmicrohttpd.so.10 (0x00007f402a822000)
        libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007f402a5b5000)
        libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007f402a1d0000)
        libhwloc.so.5 => /usr/lib64/libhwloc.so.5 (0x00007f4029fa8000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f4029da3000)
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f4029a9d000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f4029819000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f4029602000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f402926e000)
        /lib64/ld-linux-x86-64.so.2 (0x000055930ad6d000)
        libgnutls.so.26 => /usr/lib64/libgnutls.so.26 (0x00007f4028fbe000)
        libgcrypt.so.11 => /lib64/libgcrypt.so.11 (0x00007f4028d48000)
        libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x00007f4028b44000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f402893c000)
        libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f40286f7000)
        libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f4028410000)
        libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f402820c000)
        libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f4027fdf000)
        libz.so.1 => /lib64/libz.so.1 (0x00007f4027dc9000)
        libnuma.so.1 => /usr/lib64/libnuma.so.1 (0x00007f4027bbe000)
        libpci.so.3 => /lib64/libpci.so.3 (0x00007f40279b1000)
        libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00007f402765e000)
        libtasn1.so.3 => /usr/lib64/libtasn1.so.3 (0x00007f402744e000)
        libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f4027242000)
        libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f402703f000)
        libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f4026e25000)
        libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f4026c05000)

        1. In fact to build it completely static all library used in xmr-stak should be static,too. xmr-stak does not support complete static (at present) and I doubt you can do it yourself it is pretty though to do it if it is possible at all.

          1. This is too difficult. I am not familiar with binary compilation. I have someone else compiling xmr-stak and it is compatible with most Linux operating systems. Can you teach me how he handles it? If you can, please leave an e-mail and I will send it to you.

  3. This is the display under Centos7:
    [root@localhost ~]# ldd xmr-stak
    linux-vdso.so.1 => (0x00007ffd33f68000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8364dd1000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f8364bcd000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f83648cb000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f83644fe000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f8364fed000)

    This is the display under Ububtu 16.4.1 :
    root@jjj-virtual-machine:~# ldd xmr-stak
    linux-vdso.so.1 => (0x00007ffe81da4000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff797d84000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff797b80000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff797876000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff7974ad000)
    /lib64/ld-linux-x86-64.so.2 (0x000055643aa11000)

    This is the display under Centos6 :
    [root@localhost jjjj]# ldd xmr-stak
    linux-vdso.so.1 => (0x00007ffdbfd8b000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x000000317fe00000)
    libdl.so.2 => /lib64/libdl.so.2 (0x000000317f600000)
    libm.so.6 => /lib64/libm.so.6 (0x0000003180600000)
    libc.so.6 => /lib64/libc.so.6 (0x000000317fa00000)
    /lib64/ld-linux-x86-64.so.2 (0x0000561879b0d000)

    1. What I want to express is that my friend’s compiled xmr-stak will call different path library files according to different operating systems. I want to know how he did it.

Leave a Reply to rocke Cancel reply

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