AvianNetwork / Avian

Avian Network is a proof-of-work secured blockchain designed for efficient and interoperable asset management.
https://avn.network
MIT License
55 stars 25 forks source link

Documentation - build unix - Berkeley DB section is obsolete and buggy - It needs to be updated #35

Closed blackmennewstyle closed 2 years ago

blackmennewstyle commented 2 years ago

Hello,

I was trying to build the project on my Raspberry Pi 4 8 GB running GNU/Linux Debian 11 with kernel 5.10.0-9-arm64 and i would like to point out that the following section in the documentation is obsolete and buggy - https://github.com/AvianNetwork/Avian/blob/master/doc/build-unix.md#berkeley-db - The method described here will not work, it is necessary to update the config.guess and config.sub files, otherwise it will not work on modern computer configuration/architecture. The OG bitcoin actually provides a very good script which allows to install BekerleyDB 4.8 on recent architecture - https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/install_db4.sh - You guys might want to have a look:

# The packaged config.guess and config.sub are ancient (2009) and can cause build issues.
# Replace them with modern versions.
# See https://github.com/bitcoin/bitcoin/issues/16064
CONFIG_GUESS_URL='https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=4550d2f15b3a7ce2451c1f29500b9339430c877f'
CONFIG_GUESS_HASH='c8f530e01840719871748a8071113435bdfdf75b74c57e78e47898edea8754ae'
CONFIG_SUB_URL='https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=4550d2f15b3a7ce2451c1f29500b9339430c877f'
CONFIG_SUB_HASH='3969f7d5f6967ccc6f792401b8ef3916a1d1b1d0f0de5a4e354c95addb8b800e'

rm -f "dist/config.guess"
rm -f "dist/config.sub"

http_get "${CONFIG_GUESS_URL}" dist/config.guess "${CONFIG_GUESS_HASH}"
http_get "${CONFIG_SUB_URL}" dist/config.sub "${CONFIG_SUB_HASH}"

Here, i managed to install AVIAN on my Raspberry Pi 4 8GB

wget https://github.com/AvianNetwork/Avian/archive/refs/tags/v3.1.0.tar.gz
tar -xvf v3.1.0.tar.gz
cd Avian-3.1.0/

Installation of BekerleyDB 4.8 using the script from bitcoin:

cd depends/
wget https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/install_db4.sh
chmod +x install_db4.sh
cd ../

One of the nice benefits of this script, is the suggestions made at the end of its execution:

./depends/install_db4.sh `pwd`
db4 build complete.

When compiling bitcoind, run `./configure` in the following way:

  export BDB_PREFIX='/home/ceedii/Avian-3.1.0/db4'
  ./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include" ...

As you can see, the script provides a way to link the newly compiled BerkeleyDB4.8 with the configure file. So, let's proceed:

./autogen.sh
export BDB_PREFIX='/home/ceedii/Avian-3.1.0/db4'

We are lucky here, despite the differences between your project and bitcoin, the following command succeeded ./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include" --enable-hardening --disable-upnp-default and the locally built BerkeleyDB4.8 is successfully integrated:

configure: running /bin/bash ./configure --disable-option-checking '--prefix=/usr/local'  'BDB_LIBS=-L/home/ceedii/Avian-3.1.0/db4/lib -ldb_cxx-4.8' 'BDB_CFLAGS=-I/home/ceedii/Avian-3.1.0/db4/include' '--enable-hardening' '--disable-upnp-default' '--disable-shared' '--with-pic' '--with-bignum=no' '--enable-module-recovery' '--disable-jni' --cache-file=/dev/null --srcdir=.
Options used to compile and link:
  build avian-cli = yes
  build avian-tx  = no
  with wallet     = yes
  with gui / qt   = yes
    qt version    = 5
    with qr       = yes
  with zmq        = yes
  with test       = yes
  with bench      = yes
  with upnp       = yes
  use asm         = yes
  debug enabled   = no
  werror          = no

  target os       = linux
  build os        = 

  CC              = gcc
  CFLAGS          = -g -O2
  CPPFLAGS        =  -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -fPIC
  CXX             = g++ -std=c++11
  CXXFLAGS        = -g -O2 -Wall -Wextra -Wformat -Wvla -Wformat-security -Wno-unused-parameter -Wno-implicit-fallthrough -fPIC
  LDFLAGS         = 
  ARFLAGS         = cr

Let's finish the build and installation:

make -j 4

Finally, with root privileges:

make install

Et voilà, we are done :)

fdoving commented 2 years ago

I created PR #37 to add the script.

alamshafil commented 2 years ago

Nice! @fdoving pull request #37 has been merged!