说,我有一个非常简单的程序,它使用cstdlib
:
#include <cstdlib>
main() {}
使用以下命令行编译就好了:
$ g++ test.cc -o test
但有时make
附加一个-isystem /usr/include
,根据isystem
的用法,它似乎毫无用处。然而,这会导致编译错误:
$ g++ test.cc -o test -isystem /usr/include -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-gentoo-freebsd11.0/6.4.0/lto-wrapper
Target: x86_64-gentoo-freebsd11.0
Configured with: /var/tmp/portage/sys-devel/gcc-6.4.0/work/gcc-6.4.0/configure --host=x86_64-gentoo-freebsd11.0 --build=x86_64-gentoo-freebsd11.0 --prefix=/usr --bindir=/usr/x86_64-gentoo-freebsd11.0/gcc-bin/6.4.0 --includedir=/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include --datadir=/usr/share/gcc-data/x86_64-gentoo-freebsd11.0/6.4.0 --mandir=/usr/share/gcc-data/x86_64-gentoo-freebsd11.0/6.4.0/man --infodir=/usr/share/gcc-data/x86_64-gentoo-freebsd11.0/6.4.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include/g++-v6 --with-python-dir=/share/gcc-data/x86_64-gentoo-freebsd11.0/6.4.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 6.4.0 p1.0' --disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-multilib --disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --disable-libcilkrts --disable-libmpx --disable-vtable-verify --disable-libvtv --enable-lto --without-isl --disable-libsanitizer --disable-default-pie --enable-default-ssp
Thread model: posix
gcc version 6.4.0 (Gentoo 6.4.0 p1.0)
COLLECT_GCC_OPTIONS='-o' 'test' '-isystem' '/usr/include' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/libexec/gcc/x86_64-gentoo-freebsd11.0/6.4.0/cc1plus -quiet -v -isystem /usr/include test.cc -quiet -dumpbase test.cc -mtune=generic -march=x86-64 -auxbase test -version -o /tmp//cclevcZR.s
GNU C++14 (Gentoo 6.4.0 p1.0) version 6.4.0 (x86_64-gentoo-freebsd11.0)
compiled by GNU C version 6.4.0, GMP version 6.1.2, MPFR version 3.1.5-p2, MPC version 1.0.3, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/../../../../x86_64-gentoo-freebsd11.0/include"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include
/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include/g++-v6
/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include/g++-v6/x86_64-gentoo-freebsd11.0
/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include/g++-v6/backward
/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include
/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include-fixed
End of search list.
GNU C++14 (Gentoo 6.4.0 p1.0) version 6.4.0 (x86_64-gentoo-freebsd11.0)
compiled by GNU C version 6.4.0, GMP version 6.1.2, MPFR version 3.1.5-p2, MPC version 1.0.3, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 2edeed218f8bfd16af7f8b4e68596a6d
In file included from test.cc:1:0:
/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include/g++-v6/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
#include_next <stdlib.h>
^
compilation terminated.
GCC 5.4在GCC 6.4没有出现这个问题。
这是因为我的配置有什么问题(例如,当引导GCC之类的时候)或者仅仅是GCC 6中的错误?如何解决这个问题?