Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clang Error - stddef file not found?

After upgrading to Ubuntu 13.10 "Saucy", Clang now gives me the error message:

clang -Wall -Werror -std=c99 -ggdb -O0 5.1.c -o 5.1
In file included from 5.1.c:1:
/usr/include/stdio.h:33:11: fatal error: 'stddef.h' file not found
# include <stddef.h>
          ^
1 error generated.
make: *** [5.1] Error 1

BTW the header I included was stdio.h not stddef.h but I am assuming that stdio.h references or #includes stddef.h

like image 960
haziz Avatar asked Dec 14 '13 19:12

haziz


3 Answers

This error appeared for me when trying to run clang-tidy without clang installed.

Installing clang fixed this error. IMO this error occurs when clang-tidy looks for headers in GCC and system paths and clang version/symlink of these headers are missing.

like image 176
Mohammad Azim Avatar answered Nov 01 '22 13:11

Mohammad Azim


It's a know bug in ubuntu. Take a look here: https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1242300

It appears that a temporary workaround is to correct the symlink:

For the 3.5 LLVM toolchain it seems that the symlink /usr/lib/clang/3.5/include erroneously points to ../../llvm-3.4/lib/clang/3.5/include, but should instead point to ../../llvm-3.5/lib/clang/3.5/include

The workaround (of course) is to manually correct the symlink.

For the 3.4 toolchain the /usr/lib/clang/3.4/include doesn't exist at all. I have not tried LLVM 3.4 on Ubuntu so I don't know if createing a symlink to ../../llvm-3.4/lib/clang/3.4/include will fix the problem, but it does seem likely.

Source

like image 9
Glabsounet Avatar answered Nov 01 '22 12:11

Glabsounet


Please note that I resolved the above error by performing:

$ sudo apt-get install clang

In my particular case, there is likely an issue with something in my cmake files which I haven't determined yet.

like image 1
user8128167 Avatar answered Nov 01 '22 12:11

user8128167