imagemin-optipng icon indicating copy to clipboard operation
imagemin-optipng copied to clipboard

Fails to build on Apple Silicon devices (Arm64)

Open john-terrell opened this issue 3 years ago • 3 comments

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

john-terrell avatar Dec 29 '21 17:12 john-terrell

@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.

rubnogueira avatar Dec 06 '22 15:12 rubnogueira

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.

stevethemacguy avatar Feb 14 '23 19:02 stevethemacguy

@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!

luizfm avatar Sep 06 '23 18:09 luizfm