G++ build is broken after update. Cant build simple C++ programs

I’m not sure about the origin of the issue but i noticed some of my libraries were not correctly linked. One of the lib**.so.5 was a folder instead of being a soft link to lib**.so.5.1. I removed said packages and reinstalled them and updated the system using dnf update. I did that since my neovim was not working because of that fauly library. The dnf update was huge and then I resumed working on my cuda code and noticed that it didn’t build. So i tried to see how bad the issue is by checking if a simple c++ program would build with g++ code.c -o code
This too failed with a huge set of “has no declaration” errors. I have provided partial logs(due to size limitation on max characters) here

In file included from /usr/include/c++/11/x86_64-redhat-linux/bits/c++config.h:2732,
                 from /usr/include/c++/11/iostream:38,
                 from mapTest.cpp:1:
/usr/include/c++/11/x86_64-redhat-linux/bits/os_defines.h:44:19: error: missing binary operator before token "("
   44 | #if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE)
      |                   ^
/usr/include/c++/11/x86_64-redhat-linux/bits/os_defines.h:52:19: error: missing binary operator before token "("
   52 | #if __GLIBC_PREREQ(2, 27)
      |                   ^
/usr/include/c++/11/x86_64-redhat-linux/bits/os_defines.h:64:19: error: missing binary operator before token "("
   64 | #if __GLIBC_PREREQ(2, 34)
      |                   ^
In file included from /usr/include/c++/11/bits/postypes.h:40,
                 from /usr/include/c++/11/iosfwd:40,
                 from /usr/include/c++/11/ios:38,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from mapTest.cpp:1:
/usr/include/c++/11/cwchar:64:11: error: ‘mbstate_t’ has not been declared in ‘::’
   64 |   using ::mbstate_t;
      |           ^~~~~~~~~
/usr/include/c++/11/cwchar:141:11: error: ‘wint_t’ has not been declared in ‘::’
  141 |   using ::wint_t;
      |           ^~~~~~
/usr/include/c++/11/cwchar:143:11: error: ‘btowc’ has not been declared in ‘::’
  143 |   using ::btowc;
      |           ^~~~~
/usr/include/c++/11/cwchar:144:11: error: ‘fgetwc’ has not been declared in ‘::’
  144 |   using ::fgetwc;
      |           ^~~~~~
/usr/include/c++/11/cwchar:145:11: error: ‘fgetws’ has not been declared in ‘::’
  145 |   using ::fgetws;
      |           ^~~~~~
/usr/include/c++/11/cwchar:146:11: error: ‘fputwc’ has not been declared in ‘::’
  146 |   using ::fputwc;
      |           ^~~~~~
/usr/include/c++/11/cwchar:147:11: error: ‘fputws’ has not been declared in ‘::’
  147 |   using ::fputws;
      |           ^~~~~~
/usr/include/c++/11/cwchar:148:11: error: ‘fwide’ has not been declared in ‘::’
  148 |   using ::fwide;
      |           ^~~~~
/usr/include/c++/11/cwchar:149:11: error: ‘fwprintf’ has not been declared in ‘::’
  149 |   using ::fwprintf;
      |           ^~~~~~~~
/usr/include/c++/11/cwchar:150:11: error: ‘fwscanf’ has not been declared in ‘::’
  150 |   using ::fwscanf;
      |           ^~~~~~~
/usr/include/c++/11/cwchar:151:11: error: ‘getwc’ has not been declared in ‘::’
  151 |   using ::getwc;
      |           ^~~~~
/usr/include/c++/11/cwchar:152:11: error: ‘getwchar’ has not been declared in ‘::’
  152 |   using ::getwchar;
      |           ^~~~~~~~
/usr/include/c++/11/cwchar:153:11: error: ‘mbrlen’ has not been declared in ‘::’
  153 |   using ::mbrlen;
      |           ^~~~~~
/usr/include/c++/11/cwchar:154:11: error: ‘mbrtowc’ has not been declared in ‘::’
  154 |   using ::mbrtowc;
      |           ^~~~~~~
/usr/include/c++/11/cwchar:155:11: error: ‘mbsinit’ has not been declared in ‘::’
  155 |   using ::mbsinit;
      |           ^~~~~~~
/usr/include/c++/11/cwchar:156:11: error: ‘mbsrtowcs’ has not been declared in ‘::’
  156 |   using ::mbsrtowcs;
      |           ^~~~~~~~~
/usr/include/c++/11/cwchar:157:11: error: ‘putwc’ has not been declared in ‘::’
  157 |   using ::putwc;
      |           ^~~~~
/usr/include/c++/11/cwchar:158:11: error: ‘putwchar’ has not been declared in ‘::’
  158 |   using ::putwchar;
      |           ^~~~~~~~
/usr/include/c++/11/cwchar:160:11: error: ‘swprintf’ has not been declared in ‘::’
  160 |   using ::swprintf;
      |           ^~~~~~~~
/usr/include/c++/11/cwchar:162:11: error: ‘swscanf’ has not been declared in ‘::’
  162 |   using ::swscanf;
      |           ^~~~~~~
/usr/include/c++/11/cwchar:163:11: error: ‘ungetwc’ has not been declared in ‘::’
  163 |   using ::ungetwc;
      |           ^~~~~~~
/usr/include/c++/11/cwchar:164:11: error: ‘vfwprintf’ has not been declared in ‘::’
  164 |   using ::vfwprintf;
      |           ^~~~~~~~~
/usr/include/c++/11/cwchar:166:11: error: ‘vfwscanf’ has not been declared in ‘::’
  166 |   using ::vfwscanf;
      |           ^~~~~~~~
/usr/include/c++/11/cwchar:169:11: error: ‘vswprintf’ has not been declared in ‘::’
  169 |   using ::vswprintf;
      |           ^~~~~~~~~
/usr/include/c++/11/cwchar:172:11: error: ‘vswscanf’ has not been declared in ‘::’
  172 |   using ::vswscanf;
      |           ^~~~~~~~
/usr/include/c++/11/cwchar:174:11: error: ‘vwprintf’ has not been declared in ‘::’
  174 |   using ::vwprintf;
      |           ^~~~~~~~
/usr/include/c++/11/cwchar:176:11: error: ‘vwscanf’ has not been declared in ‘::’
  176 |   using ::vwscanf;
      |           ^~~~~~~
/usr/include/c++/11/cwchar:178:11: error: ‘wcrtomb’ has not been declared in ‘::’
  178 |   using ::wcrtomb;
      |           ^~~~~~~
/usr/include/c++/11/cwchar:179:11: error: ‘wcscat’ has not been declared in ‘::’
  179 |   using ::wcscat;
      |           ^~~~~~
/usr/include/c++/11/cwchar:180:11: error: ‘wcscmp’ has not been declared in ‘::’
  180 |   using ::wcscmp;
      |           ^~~~~~
/usr/include/c++/11/cwchar:181:11: error: ‘wcscoll’ has not been declared in ‘::’
  181 |   using ::wcscoll;
      |           ^~~~~~~
/usr/include/c++/11/cwchar:182:11: error: ‘wcscpy’ has not been declared in ‘::’
  182 |   using ::wcscpy;
      |           ^~~~~~
/usr/include/c++/11/cwchar:183:11: error: ‘wcscspn’ has not been declared in ‘::’
  183 |   using ::wcscspn;
      |           ^~~~~~~
/usr/include/c++/11/cwchar:184:11: error: ‘wcsftime’ has not been declared in ‘::’
  184 |   using ::wcsftime;
      |           ^~~~~~~~
/usr/include/c++/11/cwchar:185:11: error: ‘wcslen’ has not been declared in ‘::’
  185 |   using ::wcslen;
      |           ^~~~~~
/usr/include/c++/11/cwchar:186:11: error: ‘wcsncat’ has not been declared in ‘::’
  186 |   using ::wcsncat;
      |           ^~~~~~~
/usr/include/c++/11/cwchar:187:11: error: ‘wcsncmp’ has not been declared in ‘::’
  187 |   using ::wcsncmp;
      |           ^~~~~~~
/usr/include/c++/11/cwchar:188:11: error: ‘wcsncpy’ has not been declared in ‘::’
  188 |   using ::wcsncpy;
      |           ^~~~~~~
/usr/include/c++/11/cwchar:189:11: error: ‘wcsrtombs’ has not been declared in ‘::’
  189 |   using ::wcsrtombs;
      |           ^~~~~~~~~
/usr/include/c++/11/cwchar:190:11: error: ‘wcsspn’ has not been declared in ‘::’
  190 |   using ::wcsspn;
      |           ^~~~~~
/usr/include/c++/11/cwchar:191:11: error: ‘wcstod’ has not been declared in ‘::’
  191 |   using ::wcstod;
      |           ^~~~~~
/usr/include/c++/11/cwchar:193:11: error: ‘wcstof’ has not been declared in ‘::’
  193 |   using ::wcstof;
      |           ^~~~~~
/usr/include/c++/11/cwchar:195:11: error: ‘wcstok’ has not been declared in ‘::’
  195 |   using ::wcstok;
      |           ^~~~~~
/usr/include/c++/11/cwchar:196:11: error: ‘wcstol’ has not been declared in ‘::’
  196 |   using ::wcstol;
      |           ^~~~~~
/usr/include/c++/11/cwchar:197:11: error: ‘wcstoul’ has not been declared in ‘::’
  197 |   using ::wcstoul;
      |           ^~~~~~~
/usr/include/c++/11/cwchar:198:11: error: ‘wcsxfrm’ has not been declared in ‘::’
  198 |   using ::wcsxfrm;

I’m suspecting some library is broken but couldn’t put my finger on which one is broken.

FWIW, the first thing I would try is dnf group install "C Development Tools and Libraries".

No. That didn’t help. I did see some libraries weren’t pointing to the right .so files. I got the following prints when i entered the command you mentioned

sudo dnf group install "C Development Tools and Libraries"
[sudo] password for arvind: 
Last metadata expiration check: 0:38:06 ago on Mon 04 Apr 2022 01:38:54 AM EDT.
Dependencies resolved.
==============================================================================================
 Package             Architecture       Version                     Repository           Size
==============================================================================================
Installing group/module packages:
 ccache              x86_64             4.2.1-2.fc35                fedora              471 k
 indent              x86_64             2.2.12-8.fc35               fedora              178 k
 ltrace              x86_64             0.7.91-42.fc35              fedora              137 k
 perf                x86_64             5.16.5-200.fc35             updates             2.4 M
 strace              x86_64             5.16-1.fc35                 updates             1.4 M
Installing dependencies:
 opencsd             x86_64             1.1.1-1.fc35                fedora              268 k
Installing Groups:
 C Development Tools and Libraries
                                                                                             

Transaction Summary
==============================================================================================
Install  6 Packages

Total download size: 4.8 M
Installed size: 16 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): ltrace-0.7.91-42.fc35.x86_64.rpm                       304 kB/s | 137 kB     00:00    
(2/6): indent-2.2.12-8.fc35.x86_64.rpm                        378 kB/s | 178 kB     00:00    
(3/6): opencsd-1.1.1-1.fc35.x86_64.rpm                        1.3 MB/s | 268 kB     00:00    
(4/6): ccache-4.2.1-2.fc35.x86_64.rpm                         710 kB/s | 471 kB     00:00    
(5/6): strace-5.16-1.fc35.x86_64.rpm                          930 kB/s | 1.4 MB     00:01    
(6/6): perf-5.16.5-200.fc35.x86_64.rpm                        1.4 MB/s | 2.4 MB     00:01    
----------------------------------------------------------------------------------------------
Total                                                         1.6 MB/s | 4.8 MB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                      1/1 
  Installing       : opencsd-1.1.1-1.fc35.x86_64                                          1/6 
  Installing       : perf-5.16.5-200.fc35.x86_64                                          2/6 
  Installing       : strace-5.16-1.fc35.x86_64                                            3/6 
  Installing       : ltrace-0.7.91-42.fc35.x86_64                                         4/6 
  Installing       : indent-2.2.12-8.fc35.x86_64                                          5/6 
  Running scriptlet: ccache-4.2.1-2.fc35.x86_64                                           6/6 
  Installing       : ccache-4.2.1-2.fc35.x86_64                                           6/6 
  Running scriptlet: ccache-4.2.1-2.fc35.x86_64                                           6/6 
/sbin/ldconfig: File /lib64/libcreaterepo_c.so.0.19.0 is empty, not checked.
/sbin/ldconfig: File /lib64/libflatpak.so.0.11207.0 is empty, not checked.
/sbin/ldconfig: File /lib64/libcaca++.so.0.99.20 is empty, not checked.
/sbin/ldconfig: File /lib64/libcaca.so.0.99.20 is empty, not checked.
/sbin/ldconfig: File /lib64/libjavascriptcoregtk-4.0.so.18.20.4 is empty, not checked.
/sbin/ldconfig: File /lib64/libcxl.so.1.0.1 is empty, not checked.
/sbin/ldconfig: Cannot mmap file /lib64/libvdpau.so.1.

/sbin/ldconfig: File /lib64/libvdpau.so.1.0.0 is empty, not checked.
/sbin/ldconfig: File /lib64/libSPIRV-Tools-link.so is empty, not checked.
/sbin/ldconfig: File /lib64/libSPIRV-Tools-lint.so is empty, not checked.
/sbin/ldconfig: File /lib64/libSPIRV-Tools-opt.so is empty, not checked.
/sbin/ldconfig: File /lib64/libSPIRV-Tools-reduce.so is empty, not checked.
/sbin/ldconfig: File /lib64/libSPIRV-Tools-shared.so is empty, not checked.
/sbin/ldconfig: File /lib64/libSPIRV-Tools.so is empty, not checked.
/sbin/ldconfig: Cannot mmap file /lib64/libhpdiscovery.so.0.

/sbin/ldconfig: File /lib64/libhpdiscovery.so.0.0.1 is empty, not checked.
/sbin/ldconfig: Cannot mmap file /lib64/libhpip.so.0.

/sbin/ldconfig: File /lib64/libhpip.so.0.0.1 is empty, not checked.
/sbin/ldconfig: Cannot mmap file /lib64/libhpipp.so.0.

/sbin/ldconfig: File /lib64/libhpipp.so.0.0.1 is empty, not checked.
/sbin/ldconfig: Cannot mmap file /lib64/libhpmud.so.0.

/sbin/ldconfig: File /lib64/libhpmud.so.0.0.6 is empty, not checked.

/sbin/ldconfig: File /lib64/libcreaterepo_c.so.0.19.0 is empty, not checked.
/sbin/ldconfig: File /lib64/libflatpak.so.0.11207.0 is empty, not checked.
/sbin/ldconfig: File /lib64/libcaca++.so.0.99.20 is empty, not checked.
/sbin/ldconfig: File /lib64/libcaca.so.0.99.20 is empty, not checked.
/sbin/ldconfig: File /lib64/libjavascriptcoregtk-4.0.so.18.20.4 is empty, not checked.
/sbin/ldconfig: File /lib64/libcxl.so.1.0.1 is empty, not checked.
/sbin/ldconfig: Cannot mmap file /lib64/libvdpau.so.1.

/sbin/ldconfig: File /lib64/libvdpau.so.1.0.0 is empty, not checked.
/sbin/ldconfig: File /lib64/libSPIRV-Tools-link.so is empty, not checked.
/sbin/ldconfig: File /lib64/libSPIRV-Tools-lint.so is empty, not checked.
/sbin/ldconfig: File /lib64/libSPIRV-Tools-opt.so is empty, not checked.
/sbin/ldconfig: File /lib64/libSPIRV-Tools-reduce.so is empty, not checked.
/sbin/ldconfig: File /lib64/libSPIRV-Tools-shared.so is empty, not checked.
/sbin/ldconfig: File /lib64/libSPIRV-Tools.so is empty, not checked.
/sbin/ldconfig: Cannot mmap file /lib64/libhpdiscovery.so.0.

/sbin/ldconfig: File /lib64/libhpdiscovery.so.0.0.1 is empty, not checked.
/sbin/ldconfig: Cannot mmap file /lib64/libhpip.so.0.

/sbin/ldconfig: File /lib64/libhpip.so.0.0.1 is empty, not checked.
/sbin/ldconfig: Cannot mmap file /lib64/libhpipp.so.0.

/sbin/ldconfig: File /lib64/libhpipp.so.0.0.1 is empty, not checked.
/sbin/ldconfig: Cannot mmap file /lib64/libhpmud.so.0.

/sbin/ldconfig: File /lib64/libhpmud.so.0.0.6 is empty, not checked.

  Verifying        : ccache-4.2.1-2.fc35.x86_64                                           1/6 
  Verifying        : indent-2.2.12-8.fc35.x86_64                                          2/6 
  Verifying        : ltrace-0.7.91-42.fc35.x86_64                                         3/6 
  Verifying        : opencsd-1.1.1-1.fc35.x86_64                                          4/6 
  Verifying        : perf-5.16.5-200.fc35.x86_64                                          5/6 
  Verifying        : strace-5.16-1.fc35.x86_64                                            6/6 

Installed:
  ccache-4.2.1-2.fc35.x86_64    indent-2.2.12-8.fc35.x86_64   ltrace-0.7.91-42.fc35.x86_64  
  opencsd-1.1.1-1.fc35.x86_64   perf-5.16.5-200.fc35.x86_64   strace-5.16-1.fc35.x86_64     

Complete!

I will try to restore these libs but I doubt that’s the problem. What else could i share which would help you narrow down the problem.

That’s odd. Have you installed software from sources other than dnf at any point that may overwrite system files?

Can you please tell us what packages these were? Did you also reinstall the -devel packages?

Can you also please share the code that you’re trying to compile so that we can try to reproduce your issue?