【发布时间】:2021-04-06 10:56:45
【问题描述】:
我正在运行全新安装的 Linux Mint 20.1,并尝试为 GPS 跟踪器编译程序,但无法编译:
In file included from /usr/include/c++/9/bits/stl_algo.h:59,
from /usr/include/c++/9/algorithm:62,
from /usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:142,
from /usr/include/x86_64-linux-gnu/qt5/QtCore/QtCore:4,
from pch.h:27:
/usr/include/c++/9/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
75 | #include_next <stdlib.h>
| ^~~~~~~~~~
compilation terminated.
我安装了一些额外的库(libusb、libmarble 和其他一些库)和qmake。
当然,stdlib.h 存在于系统中:
$ find /usr -name stdlib.h
/usr/include/x86_64-linux-gnu/bits/stdlib.h
/usr/include/bsd/stdlib.h
/usr/include/stdlib.h
/usr/include/c++/9/tr1/stdlib.h
/usr/include/c++/9/stdlib.h
/usr/include/tcl8.6/tcl-private/compat/stdlib.h
在查看了其他关于此的问题后,我重新安装了build-essential,但没有帮助。
我重新安装了 g++ 编译器,也没有运气。
我将/usr/include/c++/9/stdlib.h 复制到/usr/local/include,但它仍然抱怨缺少stdlib.h
我改了
#include_next <stdlib.h>
在cstdlib 进入
#include <stdlib.h>
才发现下一个include找不到stdlib.h;改变一个产生第三个包括等等。所以这也行不通。
顺便说一下,该程序在 Slackware 14.2 上编译并运行。
我错过了什么?
Hello-world 编译正常;一个执行malloc 的简单程序也可以编译和运行。
【问题讨论】:
-
几个月前我在Linux Mint版本升级中也遇到了一些问题stackoverflow.com/q/63537391/6865932,一些库表现出奇怪的行为,不仅如此,还有一些设备无法正常工作,我只能解决它通过重新安装系统,希望您不需要这样做。
-
诊断步骤:工具链是否已损坏或只是特定构建配置错误?尝试创建一个 hello world,包括来自 stdlib.h(比如说 malloc)的内容,手动编译。
-
两者都有效;将其添加到问题中。
-
Makefile 中的 INCLUDEPATH 中添加了一些目录。我尝试手动编译(
gcc -c xxxx -Idirectory等),但仍然缺少包含。
标签: c++ include linux-mint