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 static binary #33

Closed
sindresorhus opened this issue Dec 27, 2017 · 12 comments
Closed

Build static binary #33

sindresorhus opened this issue Dec 27, 2017 · 12 comments

Comments

@sindresorhus
Copy link
Contributor

I've done so for macOS (3d422cb), but would be nice to have a static binary for Linux and Windows too, if possible.

See: mozilla/mozjpeg#245

@thasmo
Copy link

thasmo commented Mar 15, 2018

What would I need to do, to provide a static binary for Linux or Windows? Would I be able to pull this off without any knowledge about building static binaries? :D

@sindresorhus
Copy link
Contributor Author

No idea. That's why it's still an open issue and "help wanted".

@danez
Copy link

danez commented Apr 10, 2018

This is tricky as every linux distribution seems to store the libs at different locations:
For example in gentoo it is /usr/lib/libng16.aon ubuntu 16.04 it is /usr/lib/x86_64-linux-gnu/libpng16.a. And not sure if you want to keep a list of files for each distro?

In case you want to create the new static binary in this repository with ubuntu 16.04 this would be the diff:

diff --git a/lib/install.js b/lib/install.js
index ce9fb6d..925c1fe 100644
--- a/lib/install.js
+++ b/lib/install.js
@@ -15,6 +15,8 @@ bin.run(['-version'], err => {
                let cfgExtras = '';
                if (process.platform === 'darwin') {
                        cfgExtras = 'libpng_LIBS=\'/usr/local/lib/libpng16.a -lz\' --enable-static';
+               } else if (process.platform === 'linux') {
+                        cfgExtras = 'libpng_LIBS=\'/usr/lib/x86_64-linux-gnu/libpng16.a /usr/lib/x86_64-linux-gnu/libz.a\' --enable-static';
                }
 
                const cfg = [

@tuananh
Copy link
Contributor

tuananh commented Apr 11, 2018

@danez on debian 8, i cannot locate libpng16, only libpng12

@tuananh
Copy link
Contributor

tuananh commented Apr 11, 2018

as for the location of libpng, we can use find /usr -name libpng*.a to find out and pass it over to configure command?

@danez
Copy link

danez commented Apr 11, 2018

I guess libpng12 is okay as the configure script of mozjpeg explicitly checks for it.

https://github.com/mozilla/mozjpeg/blob/master/configure.ac#L109..L112

@tuananh
Copy link
Contributor

tuananh commented Apr 11, 2018

@danez can we use CI to build static library and upload them to github release? because asking user to install autoconf, make and other stuff is a lot. that should be a last resort only.

or maybe use prebuildify-ci to build and download them and put them to vendor like currently?

@danez
Copy link

danez commented Apr 11, 2018

By default this package will try to download and use one of the precompiled binaries anyway I think, the compiling is only a fallback.

@tuananh
Copy link
Contributor

tuananh commented Apr 11, 2018

this package will try to download and use one of the precompiled binaries anyway

I dont think it does.

It only checks if the binary is good (running -version) and compile if it fails.

@tuananh
Copy link
Contributor

tuananh commented Apr 12, 2018

one question: if we static link it with libpng12, will it work on system without libpng12? will it work with libpng16?

@heisian
Copy link

heisian commented May 8, 2018

Has checking for the cjpeg binary been considered?

And if not, then downloading the various tarballs (automake, autoconf, nasm, et. al) from locked version sources to compile dependencies without sudo in order to build cjpeg locally, and then performing cleanup such that only the cjpeg binary remains?

Depending on the Linux platform and available perl, it might also need to be compiled from source which could add significant time to the build - but most machines should at least have perl5 w/ standard libraries available.

An easier route being that the user should (if they have sudo access) run the following?

Red Hat/Fedora/CentOS/Amazon Linux

yum install autoconf automake libtool nasm

Ubuntu

sudo apt-get install autoconf libtool nasm

And in regards to libpng, why not do the same, compile from source locally such that one is not trying to find a lib that may or may not exist?

@heisian
Copy link

heisian commented May 8, 2018

You can even just download the binary pre-compiled. http://rpm.pbone.net/index.php3/stat/3/srodzaj/2/search/libpng-1.6.3

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

No branches or pull requests

5 participants