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

Cannot build statically-linked binary #267

Open
eggbean opened this issue Nov 25, 2022 · 0 comments
Open

Cannot build statically-linked binary #267

eggbean opened this issue Nov 25, 2022 · 0 comments

Comments

@eggbean
Copy link

eggbean commented Nov 25, 2022

I'm trying to build a statically-linked binary as I have that I cannot use git-crypt on Oracle Linux 9.1 (and I have become pretty dependent on it).

I add the CXXFLAGS from the Makefile and add -static and -pthread, but I get these errors:

$ CXXFLAGS='-Wall -pedantic -Wno-long-long -O2 -static -pthread' make
g++ -Wall -pedantic -Wno-long-long -O2 -static -pthread -std=c++11   -c -o git-crypt.o git-crypt.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -pthread -std=c++11   -c -o commands.o commands.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -pthread -std=c++11   -c -o crypto.o crypto.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -pthread -std=c++11   -c -o gpg.o gpg.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -pthread -std=c++11   -c -o key.o key.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -pthread -std=c++11   -c -o util.o util.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -pthread -std=c++11   -c -o parse_options.o parse_options.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -pthread -std=c++11   -c -o coprocess.o coprocess.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -pthread -std=c++11   -c -o fhstream.o fhstream.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -pthread -std=c++11   -c -o crypto-openssl-10.o crypto-openssl-10.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -pthread -std=c++11   -c -o crypto-openssl-11.o crypto-openssl-11.cpp
g++ -Wall -pedantic -Wno-long-long -O2 -static -pthread -std=c++11 -o git-crypt git-crypt.o commands.o crypto.o gpg.o key.o util.o parse_options.o coprocess.o fhstream.o crypto-openssl-10.o crypto-openssl-11.o -lcrypto
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcrypto.a(b_addr.o): in function `BIO_lookup_ex':
(.text+0xcef): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcrypto.a(b_sock.o): in function `BIO_gethostbyname':
(.text+0x71): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): in function `dlfcn_globallookup':
(.text+0x13): undefined reference to `dlopen'
/usr/bin/ld: (.text+0x26): undefined reference to `dlsym'
/usr/bin/ld: (.text+0x31): undefined reference to `dlclose'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): in function `dlfcn_pathbyaddr':
(.text+0x72): undefined reference to `dladdr'
/usr/bin/ld: (.text+0xe7): undefined reference to `dlerror'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): in function `dlfcn_bind_func':
(.text+0x3f7): undefined reference to `dlsym'
/usr/bin/ld: (.text+0x4c2): undefined reference to `dlerror'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): in function `dlfcn_load':
(.text+0x531): undefined reference to `dlopen'
/usr/bin/ld: (.text+0x5a9): undefined reference to `dlclose'
/usr/bin/ld: (.text+0x5e5): undefined reference to `dlerror'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): in function `dlfcn_unload':
(.text+0x6a4): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
make: *** [Makefile:50: git-crypt] Error 1

What can I do? I'm using Debian/Ubuntu.

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

1 participant