-
Notifications
You must be signed in to change notification settings - Fork 53
Description
I was able to compile successfully on OS X but ran into some issues, so thought I would document them here.
First, I installed libcrypto and libevent using homebrew:
brew install openssl
brew install libevent
Which installs to /usr/local
Here's how I configure and make:
CC=/usr/bin/gcc LDFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include" ./configure
CC=/usr/bin/gcc LFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include" make
Note: the second command requires LFLAGS instead of LDFLAGS, otherwise it fails here:
/usr/bin/gcc -L/opt/local/lib -L/usr/local/ssl/lib -flat_namespace -dynamiclib -undefined dynamic_lookup -install_name @executable_path/libcbitcoin-network.2.0.dylib -o bin/libcbitcoin-network.2.0.dylib build/CBLibEventSockets.o build/CBCallbackQueue.o -levent_core
since the paths are hardcoded to /opt/local in the ./configure script, but my libraries reside in /usr/local and the ./configure script only looks in LDFLAGS, not LFLAGS, to test for the existence of libevent.
CONFIGFLAGS="-Wall -Wextra -Wno-uninitialized -Wno-pointer-to-int-cast -pedantic -std=gnu99 -D_GNU_SOURCE -I/opt/local/ssl/include -I/opt/local/include -I/usr/local/ssl/include"
CONFIGFLAGS+=" $CFLAGS"
CONFIGLFLAGS=" $LFLAGS"
I'm not very familiar with autoconf... but I suppose I could also edit the CONFIGFLAGS in configure.ac. Can I also add $LDFLAGS in addition to $LFLAGS? What's the difference?
After getting past setting correct lib and include paths, I failed here:
/usr/bin/gcc build/CBRPCServer.o build/asprintf.o build/main.o -L/Users/Donald/Development/Repositories/cbitcoin/bin -Wl,-rpath=/Users/Donald/Development/Repositories/cbitcoin/bin -lcbitcoin.2.0 -lcbitcoin-network.2.0 -lcbitcoin-storage.2.0 -lcbitcoin-threads.2.0 -lpthread -lcbitcoin-logging.2.0 -lcbitcoin-crypto.2.0 -lcrypto -lcbitcoin.2.0 -lcbitcoin-file-ec.2.0 -lcbitcoin-rand.2.0 -L/opt/local/lib -levent_core -levent_pthreads -o bin/cbitcoin
ld: unknown option: -rpath=/Users/Donald/Development/Repositories/cbitcoin/bin
I found out that Apple's gcc compiler does not support -rpath, but you can instead use:
DYLD_LIBRARY_PATH=$(BINDIR)
More info here: https://dev.lsstcorp.org/trac/wiki/LinkingDarwin
After that, everything compiles!