primecoin-xpmpool-compile

编译 xpmpool

安装 gcc 4.9

boost 1.55 版本以下需要使用 gcc 4.9 以下的版本 因为 ABI 兼容性问题导致

// 检查一下版本信息,如果高于 4.9 需要重装
gcc -v
sudo apt-get remove gcc g++
sudo apt-get install gcc-4.9 g++-4.9
// 做一下软连接
cd /usr/bin
sudo ln -s /usr/bin/g++-4.9 /usr/bin/g++ -f
sudo ln -s /usr/bin/gcc-4.9 /usr/bin/gcc -f

gcc -v

详细说明:
This is essentially a won’t fix. compiling boost with gcc5, which uses
C++11 ABI, changes boost ABI and breaks most reverse dependencies.
The boost maintainer decided against backporting fixes to older
boost1.55, and rename the sonames throughout as that would be
non-standard.
Boost 1.58 and later is the default in testing and unstable, and it
uses gcc5 and thus the C++11 ABI.

Thus your options are to use:
(a) gcc4.9 or lower, C++98 ABI, and debian’s boost1.55 or lower.
(b) gcc5 or better, C++11 ABI, and debian’s boost1.57 or better.

编译 boost 1.46.1

// 查看版本
dpkg -s libboost-dev | grep 'Version'
// 如果存在删掉
sudo apt-get --purge remove libboost-*
sudo apt-get --purge remove libboost-dev libboost-doc

sudo apt-get install libbz2-dev

not use icu
libicu-dev

编译可能遇到的问题:

/usr/include/boost/config/requires_threads.hpp:29:4: error: #error "Threading support unavaliable: it has been explicitly disabled with BOOST_DISABLE_THREADS"

这是因为boost是根据编译器的宏定义来判断gcc是否支持多线程,但是gcc 4.7及以上的版本使用的宏与老版本使用的宏不同,这样,boost自然就不能正确获取gcc支持多线程的宏,从而导致不能成功编译boost_thread支持的程序。解决办法是在boost/config/stdlib/libstdcpp3.hpp文件的:

#ifdef __GLIBCXX__ // gcc 3.4 and greater:
# if defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \
|| defined(_GLIBCXX__PTHREADS)

修改为

#  if defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \
|| defined(_GLIBCXX__PTHREADS) \
|| defined(_GLIBCXX_HAS_GTHREADS)

./boost/thread/xtime.hpp:23:5: error: expected identifier before numeric constant
TIME_UTC=1
libs/thread/src/pthread/timeconv.inl

修改 TIME_UTC 为 TIME_UTC_ 和 std 的冲突了

// 下面使用 stage 了这里的 prefix 就无效了
./bootstrap.sh
// 使用这个即可
./bjam --build-dir=/tmp/build-boost toolset=gcc stage


// 这个是安装了 ICU 之后的启用参数,实际操作发现还有问题需要修改,所以暂时不用 ICU
./bjam --build-dir=/tmp/build-boost -sHAVE_ICU=1 -sICU_PATH=/usr/local/include -sICU_LINK="/LIBPATH:/usr/local/lib" toolset=gcc

如果是自定义目录需要添加环境变量
修改/etc/profile, 文件末尾添加

export BOOST_INCLUDE="your install path "/include
export BOOST_LIB="your install path "/lib

在/etc/profile.d/ 中新建一个shell文件boost.sh

#!/bin/sh
export BOOST_INCLUDE_PATH=/home/tyler/Documents/boost_1_46_1
export BOOST_LIB_PATH=/home/tyler/Documents/boost_1_46_1/stage/lib
export BOOST_LIB_SUFFIX=1_46_1

source /etc/profile.d/boost.sh
以后在编译程序的时候,只需要加上 :-I$BOOST_INCLUDE_PATH - L$BOOST_LIB_PATH

卸载
将/usr/local/lib和/usr/local/include/boost两个目录下的文件直接删除就可以。

编译 wt 3.3.2

CMake 2.6,找不到 boost 换 2.8
CMake (>= 2.4), and

./bootstrap
make -j 2
sudo make install
cmake --version

wt3.3.10 需要 cmake 2.12 以上

编译依赖包

  • ZEROMQ message system
  • Google protobuf protocol
  • libwt database abstraction
  • libwt webserver
  • Postgres SQL server

ZEROMQ, czmq, protobuf : ./configure; make; sudo make install;make clean

Postgres SQL server 9.6.9 源码编译

sudo apt-get install libreadline-dev
./configure
make
sudo make install
sudo adduser postgres
sudo mkdir /usr/local/pgsql/data
sudo chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test

然后需要创建数据库

进入控制台
/usr/local/pgsql/bin/psql
创建用户
CREATE USER backend WITH PASSWORD 'XYZPASS';
创建数据库
CREATE DATABASE testdb8 OWNER backend;
赋予权限
GRANT ALL PRIVILEGES ON DATABASE testdb8 to backend;
查看当前库的表
\d
显示表具体信息
\d table_name

编译 wt 需要
使用 CMake 2.8
C++ boost library (preferably version 1.46.1 or higher)

cd wt-x.x.x
mkdir build
cd build
配置
cmake -DBOOST_ROOT=/home/tyler/Documents/boost_1_46_1 -DBOOST_DIR=/home/tyler/Documents/boost_1_46_1 -DBOOST_INCLUDE_DIRS=/home/tyler/Documents/boost_1_46_1 -DBOOST_LIB_DIRS=/home/tyler/Documents/boost_1_46_1/stage/lib -DENABLE_POSTGRES=on -DPOSTGRES_PREFIX=/usr/local/pgsql/ -DWT_CPP_11_MODE=-std=c++11 ../

如果失败了,
ccmake ../
or
cmake-gui ../

编译
make -j 2
sudo make install

编译过程如果有问题:
Linking CXX executable test.sqlite3
../src/Wt/Dbo/backend/libwtdbosqlite3.so.3.3.2: undefined reference to dlopen
../src/Wt/Dbo/backend/libwtdbosqlite3.so.3.3.2: undefined reference to dlclose
../src/Wt/Dbo/backend/libwtdbosqlite3.so.3.3.2: undefined reference to dlerror
../src/Wt/Dbo/backend/libwtdbosqlite3.so.3.3.2: undefined reference to dlsym

检查 libdl.so 是否存在,如果没有安装下面的库
apt install libc6-dev-i386

修改 D:\wt-3.3.2\test\CMakeLists.txt
找到 HAVE_SQLITE,在 TARGET_LINK_LIBRARIES 语句的最后面加上 dl 链接库

compiled library path: /usr/local/lib/

编译 openssl 1.0.2p

openssl version -a

./config --prefix=/usr/local --openssldir=/usr/local/openssl threads zlib shared
make
make test
sudo make install

make clean

如果不指定–prefix和–openssldir, 那么, 生成的文件在
/usr/local/include, /usr/local/lib, /usr/local/ssl这三个目录下
–prefix是指定include和lib install路径
–openssldir是指定bin certs man misc openssl.cnf private的安装路径

export OPENSSL_INCLUDE_PATH=”/usr/local/include/openssl/“
export OPENSSL_LIB_PATH=”/usr/local/lib/“

1.0.1k 版本,如果提示 SSLv2_method 找不到。
修改 ssl/s2_meth.c 文件 77 行,增加下面三个方法原来的三行删掉
参见

IMPLEMENT_ssl2_meth_func(SSLv2_method,
ssl2_accept, ssl2_connect, ssl2_get_method)
#else /* !OPENSSL_NO_SSL2 */

SSL_METHOD *SSLv2_method(void) { return NULL; }
SSL_METHOD *SSLv2_client_method(void) { return NULL; }
SSL_METHOD *SSLv2_server_method(void) { return NULL; }

#endif

编译 primecoind

根据上面编译的配置,修改 makefile.unix 的相关依赖路径

export BOOST_INCLUDE_PATH=/home/tyler/Documents/boost_1_46_1
export BOOST_LIB_PATH=/home/tyler/Documents/boost_1_46_1/stage/lib

需要编译以下berkeley db db-4.8.30.NC

tar -xvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix
mkdir -p build
BDB_PREFIX=$(pwd)/build
../dist/configure --disable-shared --enable-cxx --with-pic --prefix=$BDB_PREFIX
make install
cd ../..

export BDB_LIB_PATH=$BDB_PREFIX/lib
export BDB_INCLUDE_PATH=$BDB_PREFIX/include
export BDB_LIB_SUFFIX=-4.8

进入目录 primeserver/src 执行
make -f makefile.unix > log.txt 2>&1

启动服务

第一次运行需要创建数据库
-initwtdb
矿池手续费地址
-feeaddr
费用计算:
settings->Fee = GetArg("-poolfee", 10);
(block->Value * mSettings->Fee) / 100;

目标值
-target
同步完毕后需要下面的参数启动 primecoind
-gen

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/pgsql/lib:/home/tyler/Documents/boost_1_46_1/stage/lib
sudo ldconfig

启动 postgreSQL
/usr/local/pgsql/bin/pg_ctl -s -D /usr/local/pgsql/data start -w -t 120


初始化数据库+同步数据
./primecoind -rpcuser=user -rpcpassword=password -printtoconsole -initwtdb -reindex -txindex=1 -addrindex=1 -datadir="/mnt/blocks/primecoin_pool_data"

启动矿池服务
./primecoind -rpcuser=user -rpcpassword=password -printtoconsole -txindex=1 -addrindex=1 -datadir="/mnt/blocks/primecoin_pool_data" -gen

./primecoind -gen -debug -frontport=6667 -host=121.43.185.81 -feeaddr=AVjsWxuvcmjDvULpuegjKbgjrCthi2JVeq -daemon

The webserver needs to be started as:
./webserver --docroot /usr/local/share/Wt --http-address 0.0.0.0 --http-port 80