仮想通貨:Raspberry Piでウォレットビルド中にエラーとなる場合の対処

Raspberry Piで仮想通貨のウォレットアプリケーションの構築中に、JessieとStretchのパッケージの違いなどでエラーとなったことがあったため、その対処の記録です。

  1. make中にOS毎フリーズする
  2. bignum.h:56:24: error: invalid use of incomplete type ‘BIGNUM {aka struct bignum_st}’
  3. gcc: error: unrecognized command line option ‘-msse4.1’

1. make中にOS毎フリーズする

メモリが足りない可能性があります。デフォルトでSwapが100MBしか設定されていなかったため、2048MBに変更します。

$ sudo vi /etc/dphys-swapfile

CONF_SWAPSIZE=100
↓
CONF_SWAPSIZE=2048

2. bignum.h:56:24: error: invalid use of incomplete type ‘BIGNUM {aka struct bignum_st}’

Raspbian Stretchの標準のOpenSSLのパッケージは1.1.0系となっており、これを使うとエラーとなります。1.0.2系を個別にインストールします。
エラー例

  CXX      addrman.o
In file included from chainparams.h:9:0,
                 from protocol.h:13,
                 from addrman.h:9,
                 from addrman.cpp:5:
bignum.h:56:24: error: invalid use of incomplete type ‘BIGNUM {aka struct bignum_st}’
 class CBigNum : public BIGNUM
                        ^
In file included from /home/wallet/common/include/openssl/crypto.h:31:0,
                 from allocators.h:15,
                 from serialize.h:9,
                 from netbase.h:13,
                 from addrman.h:8,
                 from addrman.cpp:5:
/home/wallet/common/include/openssl/ossl_typ.h:80:16: error: forward declaration of ‘BIGNUM {aka struct bignum_st}’
 typedef struct bignum_st BIGNUM;
..... 省略                                                                                   ^
Makefile:867: recipe for target 'addrman.o' failed
make[3]: *** [addrman.o] Error 1

対処例

~ $ wget https://www.openssl.org/source/openssl-1.0.2n.tar.gz
~ $ tar xvzf openssl-1.0.2n.tar.gz
~ $ cd openssl-1.0.2n/
~/openssl-1.0.2n $ ./config --prefix=/home/wallet/common --openssldir=/home/wallet/common/openssl -fPIC shared
~/openssl-1.0.2n $ make
~/openssl-1.0.2n $ make install

~ $ cd ikuyani-coin/
~ikuyani-coin $ ./autogen.sh
~ikuyani-coin $ LD_LIBRARY_PATH=/home/wallet/common/lib \
LIBS="-lssl -lcrypto -lrt" \
CPPFLAGS=-I/home/wallet/common/include \
LDFLAGS=-L/home/wallet/common/lib \
SSL_CFLAGS=-I/home/wallet/common/include \
SSL_LIBS=-L/home/wallet/common/lib \
CRYPTO_CFLAGS=-I/home/wallet/common/include \
CRYPTO_LIBS=-L/home/wallet/common/lib \
PKG_CONFIG_PATH=/home/wallet/common/lib/pkgconfig \
PKG_CONFIG_LIBDIR=/home/wallet/common/lib \
./configure --prefix=/home/wallet/ikuyani-coin
~ikuyani-coin $ make
~ikuyani-coin $ make install

3. gcc: error: unrecognized command line option ‘-msse4.1’

Raspberry PiではSSE4.1命令が使えないため、コンパイルオプションに指定できません。Makefile.am等に存在する場合は消します。
エラー例

gcc: error: unrecognized command line option ‘-msse4.1’
Makefile:851: recipe for target 'hash/yescrypt/yescrypt.o' failed
make[3]: *** [hash/yescrypt/yescrypt.o] Error 1

対処例

if TARGET_DARWIN
hash/yescrypt/yescrypt.o: CFLAGS += -O3 -msse4.1 -funroll-loops -fomit-frame-pointer
else
hash/yescrypt/yescrypt.o: CFLAGS += -msse4.1 -fPIC
endif

↓

if TARGET_DARWIN
hash/yescrypt/yescrypt.o: CFLAGS += -O3 -funroll-loops -fomit-frame-pointer
else
hash/yescrypt/yescrypt.o: CFLAGS += -fPIC
endif