Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

g++ 4.6 issue no <bits/c++config.h> file as required by the header cstring

Tags:

There is no file called bits/c++config.h in the c++ include directory which is required by the cstring header file. But when I include the the header cstring and compile with g++, it does not give me error. The problem occurred when I tried to compile the program with clang++ compiler in the following way.

$clang++ -cc1 -I/usr/include -I/usr/include/c++/4.6.1 -I/usr/lib/gcc/i686-linux-gnu/4.6.1 -I/usr/include/i386-linux-gnu -I opt_149739_build/include hello.cpp  In file included from /media/space/hello.cpp:2: In file included from /media/space/opt_149739_build/include/clang/Driver/Driver.h:13: In file included from /media/space/opt_149739_build/include/clang/Basic/Diagnostic.h:17: In file included from /media/space/opt_149739_build/include/clang/Basic/DiagnosticIDs.h:18: In file included from /media/space/opt_149739_build/include/llvm/ADT/StringRef.h:14: /usr/include/c++/4.6.1/cstring:42:10: fatal error: 'bits/c++config.h' file not found #include <bits/c++config.h> 

I am using g++ 4.6.1 on Ubuntu 11.04

What went wrong?

like image 949
A. K. Avatar asked Feb 08 '12 21:02

A. K.


1 Answers

The file bits/c++config.h is the platform specific include relative to the current compiler, so it is hidden in another directory, searched by default by g++, but not by clang++, as it seems.

In my machine, running locate c++config.h gives the following (relevant) files:

/usr/include/c++/4.6/i686-linux-gnu/64/bits/c++config.h /usr/include/c++/4.6/i686-linux-gnu/bits/c++config.h 

The first one is for 64-bits and the second one for 32-bits.

So just add -I/usr/include/c++/4.6/i686-linux-gnu or -I/usr/include/c++/4.6/i686-linux-gnu/64 or whatever you need for your platform.

like image 63
rodrigo Avatar answered Oct 24 '22 21:10

rodrigo