jpegoptim-bin icon indicating copy to clipboard operation
jpegoptim-bin copied to clipboard

Doesn't work on new Apple M1 chip

Open cimmwolf opened this issue 4 years ago • 6 comments

Hello. I have an error when install package. How can I use it on Apple Silicone?

yarn add v1.22.10
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
error /Users/denis/Projects/Jpegoptim/node_modules/jpegoptim-bin: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments: 
Directory: /Users/denis/Projects/Jpegoptim/node_modules/jpegoptim-bin
Output:
⚠ Command failed: /Users/denis/Projects/Jpegoptim/node_modules/jpegoptim-bin/vendor/jpegoptim --version
dyld: Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.9.dylib
  Referenced from: /Users/denis/Projects/Jpegoptim/node_modules/jpegoptim-bin/vendor/jpegoptim
  Reason: no suitable image found.  Did find:
	/usr/local/opt/jpeg/lib/libjpeg.9.dylib: mach-o, but wrong architecture
	/opt/homebrew/Cellar/jpeg/9d/lib/libjpeg.9.dylib: mach-o, but wrong architecture


  ⚠ jpegoptim pre-build test failed
  ℹ compiling from source
  ✖ Error: Command failed: /bin/sh -c ./configure --prefix="/Users/denis/Projects/Jpegoptim/node_modules/jpegoptim-bin/vendor" --bindir="/Users/denis/Projects/Jpegoptim/node_modules/jpegoptim-bin/vendor"

checking build system type... arm-apple-darwin20.3.0
checking host system type... arm-apple-darwin20.3.0
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 for a BSD-compatible install... /usr/bin/install -c
checking whether make sets $(MAKE)... yes
checking for jpeg_read_header in -ljpeg... no
Cannot find libjpeg or you have too old version (v6 or later required).

    at /Users/denis/Projects/Jpegoptim/node_modules/execa/index.js:231:11
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 0)
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

cimmwolf avatar Feb 22 '21 18:02 cimmwolf

@cimmwolf Would you try brew reinstall jpeg before installing jpegoptim-bin?

1000ch avatar Feb 28 '21 07:02 1000ch

Hello, I'm encountering the same issue. brew reinstall jpeg did not fix the issue for me.

Golmote avatar Mar 04 '21 08:03 Golmote

Hello again, thanks to help from the jpegoptim owner, I managed to install jpegoptim-bin but I had to set flags first:

CPPFLAGS="-I /opt/homebrew/Cellar/jpeg/9d/include" LDFLAGS="-L /opt/homebrew/Cellar/jpeg/9d/lib" npm install --save-dev jpegoptim-bin

This works, but any chance it could be detected and applied automatically?

Golmote avatar Mar 05 '21 08:03 Golmote

Hello again, thanks to help from the jpegoptim owner, I managed to install jpegoptim-bin but I had to set flags first:

CPPFLAGS="-I /opt/homebrew/Cellar/jpeg/9d/include" LDFLAGS="-L /opt/homebrew/Cellar/jpeg/9d/lib" npm install --save-dev jpegoptim-bin

This works, but any chance it could be detected and applied automatically?

This helped me, changing 9d to 9e (probably a newer jpeg version) did the trick. Thanks!

ramonfritsch avatar Feb 24 '22 06:02 ramonfritsch

 CPPFLAGS="-I /opt/homebrew/Cellar/jpeg/9e/include" LDFLAGS="-L /opt/homebrew/Cellar/jpeg/9e/lib/" yarn add -DT jpegoptim-bin

^ works to get the package installed on my arm64 M1 (and into package.json), however other developers that come do a yarn install it fails with the same error.

The work-around I came up with is to run the following in an .*rc/bootstrap:

    export LDFLAGS="-L $(brew --prefix jpeg)/lib/"
    export CPPFLAGS="-I $(brew --prefix jpeg)/include"

Note: this accounts for brew version upgrades (9 d/e discrepancy that @ramonfritsch mentions)

Not ideal obviously.

rynop avatar May 12 '22 17:05 rynop

👀

toFrankie avatar Jun 25 '23 09:06 toFrankie