bet
bet copied to clipboard
Issues compiling static bet binary for macOS
I compiled bet
binary for macOS on macOS v11.5.2 using the following commands:
xcode-select --install
brew install zlib autoconf automake libtool gmp sqlite libsodium gettext wget curl ninja openssl libevent cmake python3 gnu-sed pyenv
pip3 install mako
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
git clone https://github.com/chips-blockchain/bet
cd bet
./configure
make
# compressed the needed files with this command
tar -czvf bet-mac-$(printf '%s' $(git describe --always)).tar.gz privatebet/bet privatebet/config
➜ bet git:(master) ✗ ls -lh bet-mac-v0.1.3-246-g8da1f19.tar.gz
-rw-r--r-- 1 satinder staff 511K 6 Sep 23:26 bet-mac-v0.1.3-246-g8da1f19.tar.gz
Copied bet-mac-v0.1.3-246-g8da1f19.tar.gz
to a fresh installed macOS VM, and executing the bet
command gives this error:
satinder@satinders-Mac privatebet % ./bet
dyld: Library not loaded: /usr/local/opt/gmp/lib/libgmp.10.dylib
Referenced from: /Users/satinder/Desktop/privatebet/./bet
Reason: image not found
zsh: abort ./bet
This means bet
is compiled with shared libraries.
I checked again ./configure --help
and found there is option to compile it with static libraries:
--enable/disable-static (default disable)
Static link sqlite3, gmp and zlib libraries
NOTE: I borrowed the ./configure
, Makefile
for bet
and external libraries Makefile
from c-lightning project and modified it to the needs of bet
's code.
I gave another try compiling bet
with ./configure --enable-static
, but with make
command I encountered the following error:
➜ bet git:(master) ✗ make
CC: cc -I/usr/local/opt/[email protected]/include -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -std=gnu11 -g -fstack-protector -I ccan -I external/libwally-core/include/ -I external/libwally-core/src/secp256k1/include/ -I external/jsmn/ -I external/nng/include/ -I external/libwebsockets/include/ -I external/dlg/include/ -I . -I/usr/local/include -DJSMN_PARENT_LINKS -DCOMPAT_V052=1 -DCOMPAT_V060=1 -DCOMPAT_V061=1 -DCOMPAT_V062=1 -DCOMPAT_V070=1 -DCOMPAT_V072=1 -DCOMPAT_V073=1 -DCOMPAT_V080=1 -DCOMPAT_V081=1 -DCOMPAT_V082=1 -DCOMPAT_V090=1 -c -o
LD: cc -L/usr/local/opt/[email protected]/lib config.vars -Lexternal/x86_64-apple-darwin20.6.0 -lwallycore -lsecp256k1 -ljsmn -lnng -lwebsockets -ldlg -L/usr/local/lib -Wl,-dn -lgmp -lsqlite3 -lz -Wl,-dy -lm -lpthread -ldl -o
cc ccan/ccan/cdump/tools/cdump-enumstr.c
cc ccan/ccan/cdump/cdump.c
cc ccan/ccan/strmap/strmap.c
...
...
...
cc ccan/ccan/utf8/utf8.c
cc -I/usr/local/opt/[email protected]/include -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -std=gnu11 -g -fstack-protector -I ccan -I external/libwally-core/include/ -I external/libwally-core/src/secp256k1/include/ -I external/jsmn/ -I external/nng/include/ -I external/libwebsockets/include/ -I external/dlg/include/ -I . -I/usr/local/include -DJSMN_PARENT_LINKS -DCOMPAT_V052=1 -DCOMPAT_V060=1 -DCOMPAT_V061=1 -DCOMPAT_V062=1 -DCOMPAT_V070=1 -DCOMPAT_V072=1 -DCOMPAT_V073=1 -DCOMPAT_V080=1 -DCOMPAT_V081=1 -DCOMPAT_V082=1 -DCOMPAT_V090=1 -I/usr/local/opt/[email protected]/include -c -DJSMN_STRICT=1 -o external/x86_64-apple-darwin20.6.0/jsmn-build/jsmn.o external/jsmn/jsmn.c
ar rc external/x86_64-apple-darwin20.6.0/libjsmn.a external/x86_64-apple-darwin20.6.0/jsmn-build/jsmn.o
cc -I/usr/local/opt/[email protected]/include -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -std=gnu11 -g -fstack-protector -I ccan -I external/libwally-core/include/ -I external/libwally-core/src/secp256k1/include/ -I external/jsmn/ -I external/nng/include/ -I external/libwebsockets/include/ -I external/dlg/include/ -I . -I/usr/local/include -DJSMN_PARENT_LINKS -DCOMPAT_V052=1 -DCOMPAT_V060=1 -DCOMPAT_V061=1 -DCOMPAT_V062=1 -DCOMPAT_V070=1 -DCOMPAT_V072=1 -DCOMPAT_V073=1 -DCOMPAT_V080=1 -DCOMPAT_V081=1 -DCOMPAT_V082=1 -DCOMPAT_V090=1 -I/usr/local/opt/[email protected]/include -c -o external/x86_64-apple-darwin20.6.0/dlg-build/dlg.o external/dlg/src/dlg/dlg.c
ar rc external/x86_64-apple-darwin20.6.0/libdlg.a external/x86_64-apple-darwin20.6.0/dlg-build/dlg.o
ld ccan/ccan/cdump/tools/cdump-enumstr
ld: unknown option: -dn
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [ccan/ccan/cdump/tools/cdump-enumstr] Error 1
➜ bet git:(master) ✗
With bit of google search came across this issue with bit of hints/help: https://github.com/ElementsProject/lightning/issues/2366#issuecomment-470313697
Following comment from that issue I changed following line: https://github.com/chips-blockchain/bet/blob/8da1f1947f399d87bd32e25864f986c22007015e/Makefile#L222
to this:
LDLIBS = -L/usr/local/lib -Wl,-static -lgmp $(SQLITE3_LDLIBS) -lz -Wl,-dy -lm -lpthread -ldl $(COVFLAGS)
Just replaced -dn
to -static
. Tried again and then getting this error:
cc ccan/ccan/utf8/utf8.c
cc -I/usr/local/opt/[email protected]/include -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -std=gnu11 -g -fstack-protector -I ccan -I external/libwally-core/include/ -I external/libwally-core/src/secp256k1/include/ -I external/jsmn/ -I external/nng/include/ -I external/libwebsockets/include/ -I external/dlg/include/ -I . -I/usr/local/include -DJSMN_PARENT_LINKS -DCOMPAT_V052=1 -DCOMPAT_V060=1 -DCOMPAT_V061=1 -DCOMPAT_V062=1 -DCOMPAT_V070=1 -DCOMPAT_V072=1 -DCOMPAT_V073=1 -DCOMPAT_V080=1 -DCOMPAT_V081=1 -DCOMPAT_V082=1 -DCOMPAT_V090=1 -I/usr/local/opt/[email protected]/include -c -DJSMN_STRICT=1 -o external/x86_64-apple-darwin20.6.0/jsmn-build/jsmn.o external/jsmn/jsmn.c
ar rc external/x86_64-apple-darwin20.6.0/libjsmn.a external/x86_64-apple-darwin20.6.0/jsmn-build/jsmn.o
cc -I/usr/local/opt/[email protected]/include -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -std=gnu11 -g -fstack-protector -I ccan -I external/libwally-core/include/ -I external/libwally-core/src/secp256k1/include/ -I external/jsmn/ -I external/nng/include/ -I external/libwebsockets/include/ -I external/dlg/include/ -I . -I/usr/local/include -DJSMN_PARENT_LINKS -DCOMPAT_V052=1 -DCOMPAT_V060=1 -DCOMPAT_V061=1 -DCOMPAT_V062=1 -DCOMPAT_V070=1 -DCOMPAT_V072=1 -DCOMPAT_V073=1 -DCOMPAT_V080=1 -DCOMPAT_V081=1 -DCOMPAT_V082=1 -DCOMPAT_V090=1 -I/usr/local/opt/[email protected]/include -c -o external/x86_64-apple-darwin20.6.0/dlg-build/dlg.o external/dlg/src/dlg/dlg.c
ar rc external/x86_64-apple-darwin20.6.0/libdlg.a external/x86_64-apple-darwin20.6.0/dlg-build/dlg.o
ld ccan/ccan/cdump/tools/cdump-enumstr
ld: unknown option: -dy
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [ccan/ccan/cdump/tools/cdump-enumstr] Error 1
➜ bet git:(master) ✗
Changed -dy
to -static
too as follows and then got another error:
LDLIBS = -L/usr/local/lib -Wl,-static -lgmp $(SQLITE3_LDLIBS) -lz -Wl,-static -lm -lpthread -ldl $(COVFLAGS)
cc -I/usr/local/opt/[email protected]/include -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -std=gnu11 -g -fstack-protector -I ccan -I external/libwally-core/include/ -I external/libwally-core/src/secp256k1/include/ -I external/jsmn/ -I external/nng/include/ -I external/libwebsockets/include/ -I external/dlg/include/ -I . -I/usr/local/include -DJSMN_PARENT_LINKS -DCOMPAT_V052=1 -DCOMPAT_V060=1 -DCOMPAT_V061=1 -DCOMPAT_V062=1 -DCOMPAT_V070=1 -DCOMPAT_V072=1 -DCOMPAT_V073=1 -DCOMPAT_V080=1 -DCOMPAT_V081=1 -DCOMPAT_V082=1 -DCOMPAT_V090=1 -I/usr/local/opt/[email protected]/include -c -DJSMN_STRICT=1 -o external/x86_64-apple-darwin20.6.0/jsmn-build/jsmn.o external/jsmn/jsmn.c
ar rc external/x86_64-apple-darwin20.6.0/libjsmn.a external/x86_64-apple-darwin20.6.0/jsmn-build/jsmn.o
cc -I/usr/local/opt/[email protected]/include -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -std=gnu11 -g -fstack-protector -I ccan -I external/libwally-core/include/ -I external/libwally-core/src/secp256k1/include/ -I external/jsmn/ -I external/nng/include/ -I external/libwebsockets/include/ -I external/dlg/include/ -I . -I/usr/local/include -DJSMN_PARENT_LINKS -DCOMPAT_V052=1 -DCOMPAT_V060=1 -DCOMPAT_V061=1 -DCOMPAT_V062=1 -DCOMPAT_V070=1 -DCOMPAT_V072=1 -DCOMPAT_V073=1 -DCOMPAT_V080=1 -DCOMPAT_V081=1 -DCOMPAT_V082=1 -DCOMPAT_V090=1 -I/usr/local/opt/[email protected]/include -c -o external/x86_64-apple-darwin20.6.0/dlg-build/dlg.o external/dlg/src/dlg/dlg.c
ar rc external/x86_64-apple-darwin20.6.0/libdlg.a external/x86_64-apple-darwin20.6.0/dlg-build/dlg.o
ld ccan/ccan/cdump/tools/cdump-enumstr
ld: library not found for -lm
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [ccan/ccan/cdump/tools/cdump-enumstr] Error 1
➜ bet git:(master) ✗
I'm unsure what else to do to resolve -lm
. As I understand it must be resolvable as it's part of the build system.
Since I have ./configure
and Makefiles
derived from c-lightning, I tried --enable-static
with it too, and ended up with same errors.