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

Building a static binary #288

Open
dufferzafar opened this issue Apr 28, 2022 · 3 comments
Open

Building a static binary #288

dufferzafar opened this issue Apr 28, 2022 · 3 comments

Comments

@dufferzafar
Copy link

I want to build a static binary of duc so that I can use it on remote linux boxes easily.

I tried configure --enable-static --disable-shared and configure CFLAGS="-static" etc. but nothing works.

Any ideas?

@zevv
Copy link
Owner

zevv commented Apr 28, 2022

Static linking is always a PITA, and I don't think this is a use case i'd like to officially support. I can make this work "by hand" though:

Run configure with a lot of stuff disabled and add -static LDFLAG:

./configure --disable-cairo --disable-x11 --disable-ui LDFLAGS="-static"

Now linking fails, which seems to has to do with the order of the LDFLAGS passed to the compiler. I can make this work by running the last command manually and adding -lpthread -lz -lbz2:

gcc -Isrc/libduc -Isrc/libduc-graph -Isrc/glad -g -O2  -static -lpthread -lz -o duc src/libduc/buffer.o src/libduc/db.o src/libduc/db-tokyo.o src/libduc/db-kyoto.o src/libduc/db-leveldb.o src/libduc/db-sqlite3.o src/libduc/db-lmdb.o src/libduc/dir.o src/libduc/duc.o src/libduc/index.o src/libduc/canonicalize.o src/libduc/varint.o src/glad/glad.o src/libduc-graph/graph.o src/libduc-graph/graph-cairo.o src/libduc-graph/graph-opengl.o src/libduc-graph/graph-svg.o src/libduc-graph/graph-html.o src/duc/cmd-cgi.o src/duc/cmd-graph.o src/duc/cmd-gui.o src/duc/cmd-guigl.o src/duc/cmd-index.o src/duc/cmd-info.o src/duc/cmd-ls.o src/duc/cmd-ui.o src/duc/cmd-xml.o src/duc/ducrc.o src/duc/main.o -ltokyocabinet  -lm -lpthread -lz -lbz2

Not that gcc does not fully agree and whines about things likely not working with a static build:

warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

@l8gravely
Copy link
Collaborator

l8gravely commented Apr 29, 2022 via email

@l8gravely
Copy link
Collaborator

l8gravely commented Apr 29, 2022 via email

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

3 participants