如何修复 pngquant 的这个编译错误:“致命错误:uapi/linux/stddef.h:没有这样的文件或目录”?

如何修复 pngquant 的这个编译错误:“致命错误:uapi/linux/stddef.h:没有这样的文件或目录”?

(现有的答案并未解决这一特殊情况)

目前的错误信息是:

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

完整背景

我正在尝试编译pngquant从源代码,我正尝试将输出文件放到另一个位置。

pngquant依赖于libimagequant。下面是我构建代码的方式:

# Required dependency
apt-get install libpng16-dev

cd libimagequant-2.12.1
./configure --prefix=/usr/local/alt-location
make and sudo make install

现在pngquant轮到

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

如果我在 ubuntu 发行版上编译它,它将运行到最后并生成一个二进制文件。

$ 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/'

烟雾测试:

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

但是,如果我在 AWS ec2 实例(使用 xenial)上重复相同的过程,我会收到此错误:

$ 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

我的问题:

我该如何解决这个问题?这与这个 Linux 版本实际上是由 aws 定制的有关吗?

编辑

尝试按照建议安装错过的标题,但似乎标题已经安装。

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.

答案1

运行 apt-get install libc6-dev 它应该会得到你stddef正在寻找的库

通常,首先要 sudo apt-get install build-essential避免丢失库。

此外,如果你缺少一些库,你可以使用 apt-file 找到包含它们的包:

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

您将获得哪些软件包提供该文件的信息

相关内容