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 compiling static bet binary for macOS #263

Open
satindergrewal opened this issue Sep 6, 2021 · 0 comments
Open

Issues compiling static bet binary for macOS #263

satindergrewal opened this issue Sep 6, 2021 · 0 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@satindergrewal
Copy link
Collaborator

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/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/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: ElementsProject/lightning#2366 (comment)

Following comment from that issue I changed following line:

bet/Makefile

Line 222 in 8da1f19

LDLIBS = -L/usr/local/lib -Wl,-dn -lgmp $(SQLITE3_LDLIBS) -lz -Wl,-dy -lm -lpthread -ldl $(COVFLAGS)

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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/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.

@satindergrewal satindergrewal added the help wanted Extra attention is needed label Sep 6, 2021
@satindergrewal satindergrewal added this to the 0.1 - First Alpha milestone Sep 6, 2021
@satindergrewal satindergrewal added this to To do in Multiplayer release via automation Sep 6, 2021
@satindergrewal satindergrewal self-assigned this Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
Development

No branches or pull requests

1 participant