Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues building on OS X #39

Open
programmarchy opened this issue Nov 12, 2014 · 1 comment
Open

Issues building on OS X #39

programmarchy opened this issue Nov 12, 2014 · 1 comment

Comments

@programmarchy
Copy link

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!

@MatthewLM
Copy link
Owner

Thanks for this information. I'll get my Mac out and see what changes I can make to the Makefile to get it working. Hopefully tomorrow if I get chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants