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

compiling from source fails - what are the requirements? #108

Open
4levels opened this issue Oct 10, 2019 · 6 comments
Open

compiling from source fails - what are the requirements? #108

4levels opened this issue Oct 10, 2019 · 6 comments

Comments

@4levels
Copy link

4levels commented Oct 10, 2019

Hi,

I'm using NixOS for my servers and local VM's but I can't get optipng-bin to compile successfully when being installed via an npm dependency.
I've been tweaking and testing for well over a month now but all to no avail. Can you please help and tell us what specific libraries are expected to be where exactly?

This is the (consistent) error message I keep getting:

Error: Command failed: /bin/sh -c make install
pngrtran.c:99:1: warning: ‘png_rtran_ok’ defined but not used [-Wunused-function]
 png_rtran_ok(png_structrp png_ptr, int need_IHDR)
 ^~~~~~~~~~~~
ar: `u' modifier ignored since `D' is the default (see `U')
/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin/ld: pngtest.o: undefined reference to symbol 'stdout@@GLIBC_2.2.5'
/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin/ld: /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libc.so.6: error adding symbols: DSO missing from command line

Thanks a lot in advance!

@4levels
Copy link
Author

4levels commented Oct 10, 2019

I just started afresh by downloading the optipng source archive from this repo and compiling it manually, using the info found here https://github.com/NixOS/nixpkgs/blob/bd6ba87381ef6274a830253b60e481209d4d7c7d/pkgs/tools/graphics/optipng/default.nix
When I add the extra configure option --with-system-libpng I get the following error:

bin/ld: optipng.o: undefined reference to symbol 'fflush@@GLIBC_2.2.5'

When I however add the following env var before running configure and run ./configure and make install again, it works!

export LD=$CC
./configure  --with-system-zlib --prefix="vendor" --bindir="vendor" --with-system-libpng
make install

When adjusting the install.js file accordingly, it finally works! (sorry, being excited atm)

// From https://sourceforge.net/projects/optipng/files/OptiPNG/
await binBuild.file(path.resolve(__dirname, '../vendor/source/optipng.tar.gz'), [
	`LD=$CC ./configure --with-system-zlib --with-system-libpng --prefix="${bin.dest()}" --bindir="${bin.dest()}"`,
	'LD=$CC make install'
]);

@4levels
Copy link
Author

4levels commented Oct 11, 2019

Ok, final update. I tried more experiments with my own fork, and I can get it to work by simply calling LD=$CC npm install, without using my fork and it's adjustments. So feel free to close this issue, might be interesting for future developers though when building on non-standardized OS'es..
Might also be related to #92

@4levels 4levels changed the title optipng compiling from source fails - what are the requirements? compiling from source fails - what are the requirements? Oct 11, 2019
@chpio
Copy link

chpio commented Mar 27, 2020

Ok, final update. I tried more experiments with my own fork, and I can get it to work by simply calling LD=$CC npm install, without using my fork and it's adjustments.

thank you, putting this into your shell.nixs mkDerivation seem to work.

	pkgs.stdenv.mkDerivation {
		# name = "...";

		# buildInputs = [...];

		# workaround for npm dep compilation
		# https://github.com/imagemin/optipng-bin/issues/108
		shellHook = ''
			LD=$CC
		'';
	}

@miniBill
Copy link

I fixed it with:
nix-shell -p zlib
and then inside the shell

export LD=$CC
npm install ...

@happysalada
Copy link

Thanks for the proposed fix, with it, I get the following error and stacktrace

  ⚠ spawn /root/union/assets/node_modules/.pnpm/[email protected]/node_modules/jpegtran-bin/vendor/jp
│   ⚠ jpegtran pre-build test failed
│   ℹ compiling from source
│   ✖ Error: Command failed: /bin/sh -c ./configure --disable-shared --prefix="/root/union/assets/node_m
│ ./configure: line 8050: /usr/bin/file: No such file or directory
│ configure: error: no nasm (Netwide Assembler) found
│ checking for a BSD-compatible install... /nix/store/485sqh570qixsv9wk0d59vrvs35pqja0-coreutils-8.32/bi
│ checking whether build environment is sane... yes
│ checking for a thread-safe mkdir -p... /nix/store/485sqh570qixsv9wk0d59vrvs35pqja0-coreutils-8.32/bin/
│ checking for gawk... gawk
│ checking whether make sets $(MAKE)... yes
│ checking whether make supports nested variables... yes
│ checking whether make supports nested variables... (cached) yes
│ checking for style of include used by make... GNU
│ checking for gcc... gcc
│ checking whether the C compiler works... yes
│ checking for C compiler default output file name... a.out
│ checking for suffix of executables...
│ checking whether we are cross compiling... no
│ checking for suffix of object files... o
│ checking whether we are using the GNU C compiler... yes
│ checking whether gcc accepts -g... yes
│ checking for gcc option to accept ISO C89... none needed
│ checking whether gcc understands -c and -o together... yes
│ checking dependency style of gcc... gcc3
│ checking how to run the C preprocessor... gcc -E
│ checking for gcc... (cached) gcc
│ checking whether we are using the GNU C compiler... (cached) yes
│ checking whether gcc accepts -g... (cached) yes
│ checking for gcc option to accept ISO C89... (cached) none needed
│ checking whether gcc understands -c and -o together... (cached) yes
│ checking dependency style of gcc... (cached) gcc3
│ checking the archiver (ar) interface... ar
│ checking dependency style of gcc... gcc3
│ checking build system type... x86_64-unknown-linux-gnu
│ checking host system type... x86_64-unknown-linux-gnu
│ checking how to print strings... printf
│ checking for a sed that does not truncate output... /nix/store/xyd1a8i3sn1iah73sr3p15fx3y9v0rkc-gnused
│ checking for grep that handles long lines and -e... /nix/store/x604v97a5yi0yc07zfid76n7xqbcykmj-gnugre
│ checking for egrep... /nix/store/x604v97a5yi0yc07zfid76n7xqbcykmj-gnugrep-3.6/bin/grep -E
│ checking for fgrep... /nix/store/x604v97a5yi0yc07zfid76n7xqbcykmj-gnugrep-3.6/bin/grep -F
│ checking for ld used by gcc... gcc
│ checking if the linker (gcc) is GNU ld... no
│ checking for BSD- or MS-compatible name lister (nm)... nm
│ checking the name lister (nm) interface... BSD nm
│ checking whether ln -s works... yes
│ checking the maximum length of command line arguments... 12582912
│ checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func
│ checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_n
│ checking for gcc option to reload object files... -r
│ checking for objdump... objdump
│ checking how to recognize dependent libraries... pass_all
│ checking for dlltool... no
│ checking how to associate runtime and link libraries... printf %s\n
│ checking for archiver @FILE support... @
│ checking for strip... strip
│ checking for ranlib... ranlib
│ checking command to parse nm output from gcc object... ok
│ checking for sysroot... no
│ checking for a working dd... /nix/store/485sqh570qixsv9wk0d59vrvs35pqja0-coreutils-8.32/bin/dd
│ checking how to truncate binary pipes... /nix/store/485sqh570qixsv9wk0d59vrvs35pqja0-coreutils-8.32/bi
│ checking for mt... no
│ checking if : is a manifest tool... no
│ checking for ANSI C header files... yes
│ checking for sys/types.h... yes
│ checking for sys/stat.h... yes
│ checking for stdlib.h... yes
│ checking for string.h... yes
│ checking for memory.h... yes
│ checking for strings.h... yes
│ checking for inttypes.h... yes
│ checking for stdint.h... yes
│ checking for unistd.h... yes
│ checking for dlfcn.h... yes
│ checking for objdir... .libs
│ checking if gcc supports -fno-rtti -fno-exceptions... no
│ checking for gcc option to produce PIC... -fPIC -DPIC
│ checking if gcc PIC flag -fPIC -DPIC works... yes
│ checking if gcc static flag -static works... no
│ checking if gcc supports -c -o file.o... yes
│ checking if gcc supports -c -o file.o... (cached) yes
│ checking whether the gcc linker (gcc) supports shared libraries... yes
│ checking dynamic linker characteristics... GNU/Linux ld.so
│ checking how to hardcode library paths into programs... unsupported
│ checking whether stripping libraries is possible... yes
│ checking if libtool supports shared libraries... yes
│ checking whether to build shared libraries... no
│ checking whether to build static libraries... yes
│ checking whether ln -s works... yes
│ checking for pkg-config... no
│ checking size of size_t... 8
│ checking whether compiler supports pointers to undefined structures... yes
│ checking whether __SUNPRO_C is declared... no
│ checking for ANSI C header files... (cached) yes
│ checking stddef.h usability... yes
│ checking stddef.h presence... yes
│ checking for stddef.h... yes
│ checking for stdlib.h... (cached) yes
│ checking locale.h usability... yes
│ checking locale.h presence... yes
│ checking for locale.h... yes
│ checking for string.h... (cached) yes
│ checking for sys/types.h... (cached) yes
│ checking for an ANSI C-conforming const... yes
│ checking whether char is unsigned... no
│ checking for inline... inline
│ checking for size_t... yes
│ checking for unsigned char... yes
│ checking for unsigned short... yes
│ checking if right shift is signed... yes
│ checking for memset... yes
│ checking for memcpy... yes
│ checking libjpeg API version... 6.2
│ checking whether to include in-memory source/destination managers... yes
│ checking libjpeg shared library version... 62.2.0
│ checking whether the linker supports version scripts... yes (GNU style)
│ checking whether to use version script when building libjpeg-turbo... yes
│ checking for inline... inline __attribute__((always_inline))
│ checking whether to include arithmetic encoding support... yes
│ checking whether to include arithmetic decoding support... yes
│ checking whether to use 12-bit samples... no
│ checking whether to build TurboJPEG C wrapper... yes
│ checking whether to build TurboJPEG Java wrapper... no
│ checking if we have SIMD optimisations for cpu type... yes (x86_64)
│ checking for nasm... no
│ checking for nasmw... no
│ checking for yasm... no
│     at /root/union/assets/node_modules/.pnpm/[email protected]/node_modules/execa/index.js:231:11
│     at runMicrotasks (<anonymous>)
│     at processTicksAndRejections (internal/process/task_queues.js:93:5)
│     at async Promise.all (index 0)
└─ Failed in 2.5s
node_modules/.pnpm/[email protected][email protected]/node_modules/cssnano: Running postinstall script, done in 35ms
node_modules/.pnpm/[email protected]/node_modules/optipng-bin: Running postinstall script...
 ERROR  Command failed with exit code 1.

I added zlib libpng optipng as a dependency.
When I try to install this library, it fails on the postinstall script.
Interested in any idea.

@juboba
Copy link

juboba commented Dec 23, 2021

@happysalada add nasm to the mix!

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

5 participants