I use clang to compile most of the times when programming in c. Suddenly it has stopped working. Whenever I try to compile something it gives me this output Suppose the file name is test.c
clang test.c
In file included from test.c:1:
/usr/include/stdio.h:33:11: fatal error: 'stddef.h' file not found
# include <stddef.h>
^
1 error generated.
the source of test.c is :
#include <stdio.h>
#include <stdlib.h>
int main( int argc, char *argv[] )
{
printf("\nthis is a sample c program\n");
return EXIT_SUCCESS;
}
Note: on other compilers like gcc it still works. What should I do to get clang working back?
In case you need any info about system: I am using Ubuntu 13.10 32-bit. Text editor : Emacs.
I also tried to un-installing clang and then reinstalling still get the same errors.
I found the file in "usr/include/linux" and then pasted it into "usr/include" it doest show me error for same file now but asks for another one
In file included from test.c:1:
In file included from /usr/include/stdio.h:74:
/usr/include/libio.h:50:10: fatal error: 'stdarg.h' file not found
#include <stdarg.h>
^
1 error generated.
Now I tried to search for the new file "" and found more than 1 file with same name in different folder which makes it confusing which is the right one I need to copy paste in the directory clang wants.
Is there any other way by which I can fix the issue with header files?
Now i have found the config.h file for clang. The two variables responsible for include files are as follows in the file with their current values:
/* Relative directory for resource files */
#define CLANG_RESOURCE_DIR ""
/* Directories clang will search for headers */
#define C_INCLUDE_DIRS "/usr/include/i386-linux-gnu:/usr/include/i686-linux-gnu:/usr/include"
but I have no clue what value i should replace to get it working. Is these any way I can completely reconfigure clang?
Clang is much faster and uses far less memory than GCC. Clang aims to provide extremely clear and concise diagnostics (error and warning messages), and includes support for expressive diagnostics. GCC's warnings are sometimes acceptable, but are often confusing and it does not support expressive diagnostics.
Clang is a completely separate compiler (written entirely from scratch, using LLVM). You don't need GCC to use Clang, as can be shown in the case of FreeBSD (they completely replaced GCC with Clang/LLVM and don't install GCC in the base anymore for licensing reasons).
Long answer: Depends, it's a matter of adoption as well as other factors. For example, Apple uses LLVM (and Clang) for pretty much everything including building the kernel (previously built using GCC), bootloader and the userspace.
After spending some time I found that clang was not working due to missing header files in "/usr/include/" directory. Many other Linux users are also facing same problems. In my case this happened due to updating to new release of Ubuntu.
I removed clang by:
sudo apt-get remove clang
And then installed clang-3.3 which is different version of clang
sudo apt-get install clang-3.3
Now clang is working fine for me.
This is a known bug in Ubuntu. You can track this at the Ubuntu and Debian bugtrackers:
It appears that a temporary workaround is to install the clang-3.3
package instead.
From here: http://clang.llvm.org/doxygen/config_8h_source.html
See if you can find config.h
for Clang. It looks to be generated by the configure
process.
There are two variables listed in there that could be responsible for this.
00010 /* Relative directory for resource files */
00011 #define CLANG_RESOURCE_DIR ""
00012
00013 /* Directories clang will search for headers */
00014 #define C_INCLUDE_DIRS ""
You may either need to change those variables to reflect the proper location, or re-configure clang.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With