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

build zstd program against zstd shared lib #1854

Closed
pizzard opened this issue Oct 28, 2019 · 2 comments · Fixed by #1857
Closed

build zstd program against zstd shared lib #1854

pizzard opened this issue Oct 28, 2019 · 2 comments · Fixed by #1857
Assignees

Comments

@pizzard
Copy link

pizzard commented Oct 28, 2019

zstds cmake seems to not allow to build the zstd program against the shared libary. In deploying it to our embedded platform this leads to a almost doubled artifact size, which is a problem.

Is there a simple way to allow to build the zstd program against the zstd so library? this would reduce package size significantly.

@felixhandte
Copy link
Contributor

See #1680 for previous discussion.

If you want to do this yourself, you certainly can: you can build libzstd.so in the normal way and then build the (minimal) binary just like you would any other executable with a dynamic dependency:

make lib
cc \
  -O3 \
  -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef -Wpointer-arith -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings -Wredundant-decls -Wmissing-prototypes -Wc++-compat \
  -DXXH_NAMESPACE=ZSTD_ -DZSTD_NOBENCH -DZSTD_NODICT \
  programs/fileio.c programs/timefn.c programs/util.c programs/zstdcli.c \
  -Llib -lzstd -Ilib -Ilib/common -Ilib/compress -Ilib/decompress -Ilib/dictBuilder \
  -o zstd
# run it:
LD_LIBRARY_PATH=lib ./zstd --help

Does that help? Or are you specifically asking for us to include a build mode that does this?

@pizzard
Copy link
Author

pizzard commented Oct 29, 2019

Using your feedback, my colleague created the following PR to do this.
Activation of a build switch would be a lot easier to maintain as the code above and it did work for my cross-compiled arm platform.

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

Successfully merging a pull request may close this issue.

2 participants