Bitcoin Forum
January 23, 2019, 02:23:18 AM *
News: Latest Bitcoin Core release: 0.17.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: macOS Sierra Bitcoin build and install; ACLOCAL_PATH and DYLD_LIBRARY_PATH  (Read 998 times)
jimhash
Newbie
*
Offline Offline

Activity: 20
Merit: 0


View Profile WWW
July 25, 2017, 05:34:03 PM
 #1

I recently performed native build from source of Bitcoin using the latest tag on macOS Sierra 10.12.5.  I wanted to share a synopsis of my experience with other macOS & Unix developers.

I am not sure the best way to share this information with the Bitcoin dev community, hence this post.  Comments/feedback greatly appreciated, thank you.

Firstly, I did find following documents quite useful:

From these I installed the following Homebrew formulas:
  • autoconf
  • berkeley-db@4
  • libevent
  • m4
  • pkg-config
  • qt
  • automake
  • boost
  • libtool
  • openssl
  • protobuf
Importantly, macOS Sierra 10.12.5 comes with pre-installed versions of both m4 and libttool binaries (both installed in /usr/bin).  So for compatibility with the rest of the standard Unix Auto-Tools (pkg-config, automake, & autoconf) we install and reference Homebrew versions of m4 and libtool, overriding the original binaries.

Attention: Important Notes:
  • Unless ACLOCAL_PATH is set, configure will fail with the following error:
          configure: error: PKG_PROG_PKG_CONFIG macro not found. Please install pkg-config and re-run autogen.sh.
  • Unless DYLD_LIBRARY_PATH is set neither bitcoind or bitcoin-cli will be able to locate dependant dynamic shared platform libraries.
Setting ACLOCAL_PATH and DYLD_LIBRARY_PATH as below correct these issues.

What follows are macOS bash .profile environment settings for the following environment variables:
Env Var:Purpose:
CPPFLAGSGXX compile include path.
LDFLAGSGXX linker lib path.
bitcoin_enable_qtBuild bitcoin-cli for "full node" capability.
ACLOCAL_PATHm4 macro definition of PKG_PROG_PKG_CONFIG & others.
DYLD_LIBRARY_PATHmacOS runtime dyn lib path.
MANPATHman pages.

Code:
export MANPATH=/usr/local/share/man:$MANPATH

brew_pkgconf=/usr/local/opt/pkg-config
PATH=${brew_pkgconf}/bin:$PATH
CPPFLAGS="${CPPFLAGS} -I${brew_pkgconf}/share/aclocal"
m4path="${brew_pkgconf}/share/aclocal"
MANPATH=${brew_pkgconf}/share/man:$MANPATH

brew_libtool=/usr/local/opt/libtool
PATH=${brew_libtool}/bin:$PATH
dyld_library_path=${brew_libtool}/lib:${DYLD_LIBRARY_PATH}

LDFLAGS="${LDFLAGS} -L${brew_libtool}/lib"
CPPFLAGS="${CPPFLAGS} -I${brew_libtool}/include"
m4path="${brew_libtool}/share/aclocal:$m4path"
MANPATH=${brew_libtool}/share/man:$MANPATH

brew_m4=/usr/local/opt/m4
PATH=${brew_m4}/bin:$PATH
MANPATH=${brew_m4}/share/man:$MANPATH

brew_autoconf=/usr/local/opt/autoconf
PATH=${brew_autoconf}/bin:$PATH
# m4path="${brew_autoconf}/share/autoconf/autoconf:${brew_autoconf}/share/autoconf/m4sugar:$m4path"
export MANPATH=${brew_autoconf}/share/man:$MANPATH

brew_automake=/usr/local/opt/automake
PATH=${brew_automake}/bin:$PATH
m4path="${brew_automake}/share/aclocal-1.15:$m4path"
MANPATH=${brew_automake}/share/man:$MANPATH

brew_openssl=/usr/local/opt/openssl
PATH=${brew_openssl}/bin:$PATH
dyld_library_path=${brew_openssl}/lib:${dyld_library_path}
LDFLAGS="${LDFLAGS} -L${brew_openssl}/lib"  #  -lcrypto -lssl"
CPPFLAGS="${CPPFLAGS} -I${brew_openssl}/include"
MANPATH=${brew_openssl}/share/man:$MANPATH

brew_boost=/usr/local/opt/boost
PATH=${brew_boost}/bin:$PATH
dyld_library_path=${brew_boost}/lib:${dyld_library_path}
export LDFLAGS="${LDFLAGS} -L${brew_boost}/lib"
export CPPFLAGS="${CPPFLAGS} -I${brew_boost}/include/boost"

brew_libevent=/usr/local/opt/libevent
PATH=${brew_libevent}/bin:$PATH
dyld_library_path=${brew_libevent}/lib:${dyld_library_path}
LDFLAGS="${LDFLAGS} -L${brew_libevent}/lib"
CPPFLAGS="${CPPFLAGS} -I${brew_libevent}/include"
MANPATH=${brew_libevent}/share/man:$MANPATH

brew_bdb=/usr/local/opt/berkeley-db@4
PATH=${brew_bdb}/bin:$PATH
dyld_library_path=${brew_bdb}/lib:${dyld_library_path}
LDFLAGS="${LDFLAGS} -L${brew_bdb}/lib"
CPPFLAGS="${CPPFLAGS} -I${brew_bdb}/include"

brew_qt=/usr/local/opt/qt
PATH=${brew_qt}/bin:$PATH
dyld_library_path=${brew_qt}/lib:${dyld_library_path}
export LDFLAGS="${LDFLAGS} -L${brew_qt}/lib"
export CPPFLAGS="${CPPFLAGS} -I${brew_qt}/include"

brew_protobuf=/usr/local/opt/protobuf
PATH=${brew_protobuf}/bin:$PATH
dyld_library_path=${brew_protobuf}/lib:${dyld_library_path}
LDFLAGS="${LDFLAGS} -L${brew_protobuf}/lib"
CPPFLAGS="${CPPFLAGS} -I${brew_protobuf}/include"

# Add brew "cmake" formula *last* to environment,
brew_cmake=/usr/local/Cellar/cmake/3.9.0
PATH=$PATH:${brew_cmake}/bin
MANPATH=${brew_cmake}/share/man:$MANPATH

#Note: ACLOCAL_PATH which points to all important m4 macro definition of PKG_PROG_PKG_CONFIG & others..
export ACLOCAL_PATH=$m4path

export EDITOR=/usr/bin/nano

export bitcoin_enable_qt=yes

my_prefix=/Users/coinadm/local
export PATH=${my_prefix}/bin:$PATH
export DYLD_LIBRARY_PATH=${my_prefix}/lib:${dyld_library_path}
export LDFLAGS
export CPPFLAGS
export MANPATH

alias ez="env | egrep 'FLAG|LIB' | sort"
alias godev="cd ~/CLionProjects/bitcoin-ghc1"
alias findmakes="find . -name Makefile.in | xargs -I {} -t ls -l {}"
alias myag="./autogen.sh --with-gui=yes"
alias myconf="./configure --prefix=${my_prefix} --with-gui=yes"

# godev
# make clean
# find . -name Makefile.in | xargs -I {} -t rm -f {}"
# rm configure
# myag
# myconf
# make
# make install

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
pebwindkraft
Full Member
***
Offline Offline

Activity: 259
Merit: 241


View Profile
July 27, 2017, 07:13:55 AM
 #2

thank you for sharing. The Mac community will like it  Smiley
I used the pre-compiled binaries (and verified the checksums). Seems like I'm a bit too lazy, next time ...
Racooma
Newbie
*
Offline Offline

Activity: 50
Merit: 0


View Profile WWW
July 27, 2017, 01:08:26 PM
 #3

Did you execute `source .profile`?
jimhash
Newbie
*
Offline Offline

Activity: 20
Merit: 0


View Profile WWW
August 03, 2017, 09:20:10 PM
 #4

thank you for sharing. The Mac community will like it  Smiley
I used the pre-compiled binaries (and verified the checksums). Seems like I'm a bit too lazy, next time ...

Laziness is probably good sometimes (in moderation at least).  I like Sriram Srinivasan's characterization of the three pitfalls of IT (I'm paraphrasing here), something like:
  • False hubris.
  • False laziness.
  • False impatience.
I've been guilty if all of the above at various times.  I may have gone overboard a little here, and maybe should have erred on the side of laziness a little more myself here though.  

Anyway, this environment fell out of an attempt to create a native macOS personal development & testing environment consisting of specifically selected 3rd party packages which, in turn, are somewhat sandboxed via installation ownership & permissions.  

Unix Autotools (automake & friends) perform the system/environment probes which insulate you from needing to know these details of how to drive your compiler, linker, loader, etc.  For development purposes though, sometimes it is convenient to be explicit about particular versions of particular packages.  This type of explicit setting of CPPFLAGS and LDFLAGS can be a convenient way to do this.  

Given this, I have since learned that the official/endorsed mechanism for performing platform builds is to use Gitian(for resources see), particularly when cross-compiling.  
yg10
Newbie
*
Offline Offline

Activity: 80
Merit: 0


View Profile
August 05, 2017, 12:47:28 AM
 #5

I recently performed native build from source of Bitcoin using the latest tag on macOS Sierra 10.12.5.  I wanted to share a synopsis of my experience with other macOS & Unix developers.

I am not sure the best way to share this information with the Bitcoin dev community, hence this post.  Comments/feedback greatly appreciated, thank you.

Firstly, I did find following documents quite useful:

From these I installed the following Homebrew formulas:
  • autoconf
  • berkeley-db@4
  • libevent
  • m4
  • pkg-config
  • qt
  • automake
  • boost
  • libtool
  • openssl
  • protobuf
Importantly, macOS Sierra 10.12.5 comes with pre-installed versions of both m4 and libttool binaries (both installed in /usr/bin).  So for compatibility with the rest of the standard Unix Auto-Tools (pkg-config, automake, & autoconf) we install and reference Homebrew versions of m4 and libtool, overriding the original binaries.

Attention: Important Notes:
  • Unless ACLOCAL_PATH is set, configure will fail with the following error:
          configure: error: PKG_PROG_PKG_CONFIG macro not found. Please install pkg-config and re-run autogen.sh.
  • Unless DYLD_LIBRARY_PATH is set neither bitcoind or bitcoin-cli will be able to locate dependant dynamic shared platform libraries.
Setting ACLOCAL_PATH and DYLD_LIBRARY_PATH as below correct these issues.

.....


IMVHO the best way is:
1. Issue the command:
brew install pkg-config
and re-run installation process.
(This worked for me).
2. Open an issue on Github asking devs to update the list of software required.
(did not do that).

striker7334 2.0
Sr. Member
****
Offline Offline

Activity: 560
Merit: 300


Unprofessional shitcoin trader since 2011


View Profile
August 05, 2017, 03:08:39 AM
 #6

Nice I was looking into learning how to compile wallets and I think this would be a good guide for a noob like me. Thanks for the share!

Pages: [1]
  Print  
 
Jump to:  

Bitcointalk.org is not available or authorized for sale. Do not believe any fake listings.
Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!