You are not logged in.

#1 2022-11-27 10:11:23

mozkomor05
Member
From: Czech Republic
Registered: 2022-11-27
Posts: 2
Website

[SOLVED] g++ system standard libraries not found

Hello,

since yesterday I am suddenly unable to compile anything using g++ or clang. Unfortunately I have no clue which event could have caused the issue. All I remember is that I did a kernel upgrade.

Sample program:

#include <iostream>

int main() {
	std::cout << "Hello, World!" << std::endl;
	return 0;
}

> g++ test.cpp

test.cpp:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>

Various things I've noticed:

g++ doesn't try to find the standard libraries in /urs/include/c++. See:

❯ sudo strace -f -t -e trace=file g++ test.cpp  2>&1 | grep iostream
[pid 10625] 10:55:08 readlink("/usr/local/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/iostream", 0x7ffffbc5de10, 1023) = -1 ENOENT (No such file or directory)
[pid 10625] 10:55:08 newfstatat(AT_FDCWD, "/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/iostream.gch", 0x7ffffbc5f2e0, 0) = -1 ENOENT (No such file or directory)
[pid 10625] 10:55:08 openat(AT_FDCWD, "/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/include/iostream", O_RDONLY|O_NOCTTY) = -1 ENOENT (No such file or directory)
[pid 10625] 10:55:08 readlink("/usr/local/lib/gcc/x86_64-pc-linux-gnu/12.2.0/include-fixed/iostream", 0x7ffffbc5de10, 1023) = -1 ENOENT (No such file or directory)
[pid 10625] 10:55:08 newfstatat(AT_FDCWD, "/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/include-fixed/iostream.gch", 0x7ffffbc5f2e0, 0) = -1 ENOENT (No such file or directory)
[pid 10625] 10:55:08 openat(AT_FDCWD, "/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/include-fixed/iostream", O_RDONLY|O_NOCTTY) = -1 ENOENT (No such file or directory)
[pid 10625] 10:55:08 readlink("/usr/local/include/iostream", 0x7ffffbc5de10, 1023) = -1 ENOENT (No such file or directory)
[pid 10625] 10:55:08 newfstatat(AT_FDCWD, "/usr/local/include/iostream.gch", 0x7ffffbc5f2e0, 0) = -1 ENOENT (No such file or directory)
[pid 10625] 10:55:08 openat(AT_FDCWD, "/usr/local/include/iostream", O_RDONLY|O_NOCTTY) = -1 ENOENT (No such file or directory)
[pid 10625] 10:55:08 readlink("/usr/include/iostream", 0x7ffffbc5de10, 1023) = -1 ENOENT (No such file or directory)
[pid 10625] 10:55:08 newfstatat(AT_FDCWD, "/usr/include/iostream.gch", 0x7ffffbc5f2e0, 0) = -1 ENOENT (No such file or directory)
[pid 10625] 10:55:08 openat(AT_FDCWD, "/usr/include/iostream", O_RDONLY|O_NOCTTY) = -1 ENOENT (No such file or directory)
test.cpp:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>

This is very weird, I expected g++ to search for system libraries in /usr/include/c++/12.2.0/ and find /usr/include/c++/12.2.0/iostream as it did on my friend's machine.

Potentially useful outputs:

❯ sudo find -L /usr -name iostream -type f -print

/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/c++/iostream
/usr/lib/python3.10/site-packages/torch/include/c++/12.2.0/iostream
/usr/include/c++/12.2.0/iostream
/usr/lib64/gcc/x86_64-pc-linux-gnu/11.3.0/include/c++/iostream
/usr/lib64/python3.10/site-packages/torch/include/c++/12.2.0/iostream
/usr/local/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/c++/iostream
/usr/local/lib/python3.10/site-packages/torch/include/c++/12.2.0/iostream

❯ sudo pacman -Qk | grep gcc

gcc: 2613 total files, 0 missing files
gcc-libs: 61 total files, 0 missing files
gcc11: 1518 total files, 0 missing files
gcc11-libs: 21 total files, 0 missing files
lib32-gcc-libs: 44 total files, 0 missing files

❯ gcc -v

Reading specs from /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (GCC)

❯ g++ -v test.cpp

Reading specs from /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/specs
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/cc1plus -quiet -v -iprefix /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/ -D_GNU_SOURCE test.cpp -quiet -dumpdir a- -dumpbase test.cpp -dumpbase-ext .c -mtune=generic -march=x86-64 -version -o /tmp/ccF8JyYM.s
GNU C++17 (GCC) version 12.2.0 (x86_64-pc-linux-gnu)
	compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.25-GMP

warning: MPFR header version 4.1.0-p13 differs from library version 4.1.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0"
ignoring nonexistent directory "/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/x86_64-pc-linux-gnu"
ignoring nonexistent directory "/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/backward"
ignoring nonexistent directory "/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/include"
ignoring nonexistent directory "/usr/local/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0"
ignoring nonexistent directory "/usr/local/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/x86_64-pc-linux-gnu"
ignoring nonexistent directory "/usr/local/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/backward"
ignoring duplicate directory "/usr/local/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/12.2.0/include"
ignoring duplicate directory "/usr/local/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/12.2.0/include-fixed"
ignoring nonexistent directory "/usr/local/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/include
 /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.0/include-fixed
 /usr/local/include
 /usr/include
End of search list.
GNU C++17 (GCC) version 12.2.0 (x86_64-pc-linux-gnu)
	compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.25-GMP

warning: MPFR header version 4.1.0-p13 differs from library version 4.1.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 402ce889a414e2a3abbbe3146fa0a6cb
test.cpp:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.

❯ cat /etc/ld.so.conf.d/*

/opt/cuda/lib64
/opt/cuda/nvvm/lib64
/opt/cuda/extras/CUPTI/lib64
/usr/lib/libfakeroot
/opt/intel/oneapi/compiler/latest/linux/lib
/opt/intel/oneapi/compiler/latest/linux/lib/x64
/opt/intel/oneapi/compiler/latest/linux/lib
/opt/intel/oneapi/compiler/latest/linux/lib/x64
/opt/intel/oneapi/compiler/latest/linux/compiler/lib/intel64_lin
/opt/intel/oneapi/mkl/latest/lib/intel64
/opt/intel/oneapi/compiler/2022.1.0/linux/compiler/lib/intel64/
/opt/intel/oneapi/lib/intel64
/opt/intel/oneapi/compiler/latest/linux/compiler/lib/intel64
/opt/intel/oneapi/tbb/latest/lib/intel64/gcc4.8
/usr/lib32

What did I try?

- Reinstalling compilers with sudo pacman -Syy gcc gcc-libs clang --overwrite="*"
- Running g++ with different flags as -I/usr/include/c++/12.2.0/
- Desperate attempt to add /usr/include to /etc/ld.so.conf
- Adding /usr/include/c++ to CPLUS_INCLUDE_PATH

Last edited by mozkomor05 (2022-11-27 10:47:24)

Offline

#2 2022-11-27 10:33:44

seth
Member
Registered: 2012-09-03
Posts: 35,051

Re: [SOLVED] g++ system standard libraries not found

pacman -Syy gcc gcc-libs clang

Don't. This is a recipe for disaster.
Read the pacman manpage on what the second "y" *actually* does and then don't use it and also don't conduct partial updates. "-Sy" should usually be followed by a "u"

Did you notice all the "/usr/local/bin"?

type g++ gcc

Offline

#3 2022-11-27 10:40:17

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 10,638

Re: [SOLVED] g++ system standard libraries not found

from sudo find -L /usr -name iostream -type f -print

/usr/local/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/c++/iostream
/usr/local/lib/python3.10/site-packages/torch/include/c++/12.2.0/iostream

Looks like you have a seperate installation of gcc 11.3 / python 3.10 in /usr/local  that is used instead of the pacman installed gcc .

It must have been manually installed outside of pacman.

EDIT : post the output of the type command mentioned by Seth.

Last edited by Lone_Wolf (2022-11-27 10:41:36)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#4 2022-11-27 10:47:01

mozkomor05
Member
From: Czech Republic
Registered: 2022-11-27
Posts: 2
Website

Re: [SOLVED] g++ system standard libraries not found

Thank you both. I didn't notice such a simple thing. I also found the mistyped command which caused some programs from /usr/bin/ to be copied into /usr/local/bin in history. Next time, I will be more careful.

Offline

Board footer

Powered by FluxBB