I accidently deleted the folder with all the C++ header files that resides in /usr/include/c++. What do I do to recover the

UPDATE I did get the header files back now in /usr/include/c++. However, even a simple C++ Hello World Program is giving me this error

In file included from /usr/include/c++/4.6/bits/localefwd.h:42:0,
             from /usr/include/c++/4.6/ios:42,
             from /usr/include/c++/4.6/ostream:40,
             from /usr/include/c++/4.6/iostream:40,
             from Hello.cpp:1:
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++locale.h:53:23: error: ‘uselocale’     was not declared in this scope
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++locale.h:53:45: error: invalid type in declaration before ‘;’ token
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++locale.h: In function ‘int std::__convert_from_v(__locale_struct* const&, char*, int, const char*, ...)’:
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++locale.h:76:53: error: ‘__gnu_cxx::__uselocale’ cannot be used as a function
/usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++locale.h:101:33: error: ‘__gnu_cxx::__uselocale’ cannot be used as a function

2 Answers 2


You can get a comma separated list of packages that have installed files to /usr/include/c++ with

dpkg --search /usr/include/c++

and then run for each listed package

sudo apt-get install --reinstall
  • I got the folders back.. But im getting a new error Nov 15, 2014 at 16:05
  • Is is possible that also something from /usr/include got deleted, not only /usr/include/c++? Nov 15, 2014 at 18:32
  • I havent deleted anything for usr/include manually, but it could be possible... Its come to the state before I deleted the folder - where c++ code wasnt successfully getting compiled.. Read the question agai - i updated it to show the latest error Nov 16, 2014 at 5:10
  • do I do the same thing for /usr/include that i did for /usr/include/c++ ?? Nov 16, 2014 at 5:11
  • No, it's better to figure out if something is actually missing instead of forcing everything in, especially considering /usr/include is used by many packages. You can verify the files with first installing a support tool sudo apt-get install debsums and then checking all packages that use /usr/include with debsums -s $(dpkg --search /usr/include | cut -d: -f1 | sed 's:,::g'). That command will give output only in case of something is missing. Nov 16, 2014 at 10:46

try reinstalling g++

sudo apt-get install --reinstall g++
  • It reinstalled.. But still getting iostream missing error.Header files still missing Nov 15, 2014 at 13:58
  • AFAIK g++ is only a metapackage that depends on the default g++-4.x for your system. You will likely need to re-install the actual corresponding libstdc++xxx-dev development package. For 12.04 (default g++-4.6) I think that's libstdc++6-4.6-dev, but you might want to check first using something like dpkg -l | grep 'libstdc.*-dev' Nov 15, 2014 at 14:46
  • I got the header files back.. But im getting some new error.. read the question again - ive explained it Nov 15, 2014 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .