Emacs 25.1 on lubuntu 16.04 won't configure due to missing libpng

1.7k Views Asked by At

I am attempting to install emacs 25.1 on lubuntu 16.04, and having some trouble. After downloading and extracting the tar, I navigate to the emacs 25.1 directory then.. ./configure

The configuration stops when I receive the message

configure: error: The following required libraries were not found:
    libpng
Maybe some development libraries/packages are missing?
If you don't want to link with them give
     --with-png=no
as options to configure

When I try sudo apt install libpng-dev

I get the message

Note, selecting 'libpng12-dev' instead of 'libpng-dev' libpng12-dev is already the newest version (1.2.54-1ubuntu1). 0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded. I tried reinstalling libpng12-dev using the below string, which didn't help at all.

sudo apt-get install --reinstall libpng12-0=1.2.54-1ubuntu1

I'm stuck here, I've googled around for a while and can't find any solutions that have actually worked.

2

There are 2 best solutions below

1
On BEST ANSWER

I have the same problem. After I checked the config.log file, I found out that because I already installed Anaconda3 python

when gcc compile emacs it uses some libpng... found in Anconda3 directory. So I remove related Anaconda3 directory in PATH, everything turns out right.

The wrong version:

configure:15301: result: -lz
configure:15407: checking for png
configure:15437: gcc -o conftest  -g3 -O2 -I/etc/anaconda3/include/libpng16       conftest.c -lpng16 -lz -lm -lX11   >&5 
/usr/bin/ld: cannot find -lpng16

The right version:

configure:15301: result: -lz
configure:15407: checking for png
configure:15437: gcc -o conftest  -g3 -O2 -I/usr/include/libpng12       conftest.c -lpng12 -lz -lm -lX11   >&5 
configure:15437: $? = 0
configure:15452: result: yes

Hope that would be helpful!

1
On

The solution is to remove the default version of libpng-dev (1.2) and explicitly install version 1.6: sudo apt-get remove libpng-dev && sudo apt-get install libpng16-dev

Explicit versions of dependencies don't seem to be documented in the readme files.