imagemin / imagemin-optipng

optipng plugin for imagemin
MIT License
163 stars 36 forks source link

Fails to build on Apple Silicon devices (Arm64) #36

Open john-terrell opened 2 years ago

john-terrell commented 2 years ago

On an Apple Silicon Mac:

$ npm install imagemin-optipng --save-dev

...

Undefined symbols for architecture arm64: npm ERR! "_png_init_filter_functions_neon", referenced from: npm ERR! _png_read_filter_row in libpng.a(pngrutil.o) npm ERR! ld: symbol(s) not found for architecture arm64

rubnogueira commented 1 year ago

@john-terrell Running with the following env variable made the trick for me. export CPPFLAGS="-DPNG_ARM_NEON_OPT=0" or CPPFLAGS="-DPNG_ARM_NEON_OPT=0" npm install imagemin-optipng --save-dev

For reference, I was able to install v6.0.0 without this flag.

stevethemacguy commented 1 year ago

Is this something that can be integrated into imagemin-optipng so devs don't have to figure this out the hard way? Several of our devs lost hours on this. A normal npm install worked on my M1 mac without any flags, but not on theirs. Thank you.

luizfm commented 1 year ago

@john-terrell Running with the following env variable made the trick for me. export CPPFLAGS="-DPNG_ARM_NEON_OPT=0" or CPPFLAGS="-DPNG_ARM_NEON_OPT=0" npm install imagemin-optipng --save-dev

For reference, I was able to install v6.0.0 without this flag.

This one worked for me as well. I needed to run with the flag on my M1 in the lib version 8.0.0, using Node.js 14.20.0 on an application. Thanks!