> ## Content Index
> Fetch the complete content index at: https://connortumbleson.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# The libpng16 mozjpeg help guide.
- URL: https://connortumbleson.com/2018/06/24/libpng16-a-stressful-day/
- Published: 2018-06-24T11:32:00.000Z
- Updated: 2018-08-22T01:19:24.000Z
- Description: While trying a regular Laravel deploy, I hit an interesting libpng16 error that required a bit more work than usual to fix.
- Author: Connor Tumbleson
- Tags: Guide

One day my build scripts started failing during the creation of assets.

```
Module build failed: ModuleBuildError: Module build failed: Error: Command failed: ~/node_modules/mozjpeg/vendor/cjpeg
~/node_modules/mozjpeg/vendor/cjpeg: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory

```

So I decided to go check that binary again, to check what shared dependencies it had.

```
[~/node_modules/mozjpeg/vendor]# ldd cjpeg 
	linux-vdso.so.1 =>  (0x00007ffd5cfab000)
	libpng16.so.16 => not found
	libm.so.6 => /lib64/libm.so.6 (0x00007f4f95c44000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f4f95877000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f4f95f46000)

```

Usually, this is as easy as using yum to install `libpng16`. However, yum only had `libpng12` and `libpng15`. Instead of installing some bulky repository, I decided to install this one manually.

```
wget https://download.sourceforge.net/libpng/libpng-1.6.34.tar.gz
md5sum libpng-1.6.34.tar.gz 

```

(ensure the md5 matches the package downloaded [here](http://www.libpng.org/pub/png/libpng.html?ref=connortumbleson.com))

Next up to configure & build it.

```
LIBS=-lpthread ./configure --prefix=/usr --disable-static && make
make install
ldconfig

```

Now we've built, installed and linked the dependency into our system. If the build failed, make sure you have the following build requirements.

```
yum install libtool automake autoconf nasm

```

Rerunning the same `ldd` command, we can print out the shared dependencies.

```
[~/node_modules/mozjpeg/vendor]# ldd cjpeg 
	linux-vdso.so.1 =>  (0x00007ffe4ca8f000)
	libpng16.so.16 => /lib/libpng16.so.16 (0x00007fb440792000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fb440490000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fb4400c3000)
	libz.so.1 => /lib64/libz.so.1 (0x00007fb43fead000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb43fc91000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fb4409c4000)

```

Now my asset deploys were back to working :)

```
DONE  Compiled successfully in 43567ms                                               

```

Featured image by [Becca Tapert](https://unsplash.com/@beccatapert?utm%5Fsource=ghost&utm%5Fmedium=referral&utm%5Fcampaign=api-credit) / [Unsplash](https://unsplash.com/?utm%5Fsource=ghost&utm%5Fmedium=referral&utm%5Fcampaign=api-credit)