×

Search anything:

[Fixed] fatal error: bits/c++config.h: No such file or directory

C++ C

Internship at OpenGenus

Get this book -> Problems on Array: For Interviews and Competitive Programming

In this article, we have explored the reason behind the C++ compilation error "fatal error: bits/c++config.h: No such file or directory" and presented the fix for resolving the error.

Table of contents:

  1. Error: fatal error: bits/c++config.h
  2. Fix 1: Install G++
  3. Fix 2: Use GCC
  4. Fix 3: Add include paths

Error: fatal error: bits/c++config.h

On compiling a C++ code with G++, one may face a compilation error. The compilation command will be as follows:

g++ code.c

The compilation error is as follows:

/usr/include/c++/5/cstring:41:28: fatal error: 
  bits/c++config.h: No such file or directory
compilation terminated.

The issue is with the compiler as it is unable to find the mentioned header file bits/c++config.h which should be available by default.

Fix 1: Install G++

The first fix is to reinstall the multilib version of G++ which should work fine. We shall update the system repository so that the latest G++ version is installed.

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-multilib

To install a specific version of G++ multilib compiler, use the following command:

sudo apt-get install g++-5-multilib

Fix 2: Use GCC

Another fix will be to use a working GCC compiler and enable the flag lstdc++ to compile C++ code with a C compiler. Replace g++ with "gcc -lstdc++".

Replace:

g++ code.c

with

gcc -lstdc++ code.c

Fix 3: Add include paths

Add the following include path in G++ compiler as the header file resides there:

-I/usr/include/c++/5/i486-linux-gnu
-I/usr/include/c++/5/i686-linux-gnu

Check if the header file is available in path using ls command:

ls /usr/include/c++/5/i486-linux-gnu
OR
ls /usr/include/c++/5/i686-linux-gnu

The compilation command will be as follows:

g++ -I/usr/include/c++/5/i486-linux-gnu code.c
OR
g++ -I/usr/include/c++/5/i686-linux-gnu code.c

With this article at OpenGenus, we have resolved the error "fatal error: bits/c++config.h: No such file or directory". Continue your development.

Benjamin QoChuk, PhD

Benjamin QoChuk, PhD

Benjamin QoChuk is a Computer Science Researcher, Inventor and Author. His educational background include Bachelors at Vanderbilt University and PhD in Computer Science at Peking University.

Read More

Improved & Reviewed by:


OpenGenus Foundation OpenGenus Foundation
[Fixed] fatal error: bits/c++config.h: No such file or directory
Share this