How to fix this compilation error of pngquant: "fatal error: uapi/linux/stddef.h: No such file or directory'"?

(Existing answers do not address this particular situation)

Currently the error message is:

In file included from /usr/include/stdio.h:33:0, from pngquant.c:37:
/usr/src/linux-aws-headers-4.4.0-1075/include/linux/stddef.h:4:31: fatal error: uapi/linux/stddef.h: No such file or directory

Full Background

I am trying to compile pngquant from source and I am trying to put the output files to an alternative location.

pngquant has a dependency on libimagequant. Here is the way I build the code:

# Required dependency
apt-get install libpng16-dev
cd libimagequant-2.12.1
./configure --prefix=/usr/local/alt-location
make and sudo make install

Now it is pngquant's turn

cd pngquant-2.12.1
./configure --prefix=/usr/local/alt-location --with-libimagequant=/src/to/libimagequant

If I compile it on a ubuntu distribution, it will run to the end and a binary is generated.

$ make && sudo make install
make: Nothing to be done for 'all'.
mkdir -p '/usr/local/alt-location/bin'
mkdir -p '/usr/local/alt-location/share/man/man1'
install -m 0755 -p 'pngquant' '/usr/local/alt-location/bin/pngquant'
install -m 0644 -p 'pngquant.1' '/usr/local/alt-location/share/man/man1/'

Smoke test:

[10:20:13] sde:pngquant-2.12.1$ /usr/local/alt-location/bin/pngquant --version
2.12.0 (January 2018)

However if I repeat the same process on an AWS ec2 instance (with xenial) I got this error:

$ make
gcc -fno-math-errno -funroll-loops -fomit-frame-pointer -Wall -std=c99 -I. -O3 -DNDEBUG -DUSE_SSE=1 -msse -mfpmath=sse -Wno-unknown-pragmas -I/usr/local/alt-location/include -I/usr/include/libpng16 -I/usr/src/linux-aws-headers-4.4.0-1075/include/linux -fexcess-precision=fast -c -o pngquant.o pngquant.c
In file included from /usr/include/stdio.h:33:0, from pngquant.c:37:
/usr/src/linux-aws-headers-4.4.0-1075/include/linux/stddef.h:4:31: fatal error: uapi/linux/stddef.h: No such file or directory
compilation terminated.
<builtin>: recipe for target 'pngquant.o' failed
make: *** [pngquant.o] Error 1

My question:

How can I fix this issue? Does it has anything to do with the fact that this linux version is actually customised by aws?

Edit

Trying to install missed header as suggested but it seems the headers are already installed.

sudo apt-get install linux-headers-$(uname -r)
Reading package lists... Done
Building dependency tree
Reading state information... Done
linux-headers-4.4.0-1081-aws is already the newest version (4.4.0-1081.91).
linux-headers-4.4.0-1081-aws set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.
9

1 Answer

runapt-get install libc6-devwhich should get you stddef lib you're looking for

It's generally good idea to start with:sudo apt-get install build-essential to avoid libraries missing.

additionally, if you have some missing lib you can find packages with them with apt-file:

sudo apt-get install apt-file
apt update
apt-file search stddef.h

and you'll get info which packages provide the file

6

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like