Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clang says "cstdlib file not found"

On an almost default install of Ubuntu 11.04 I installed clang.

I am trying to compile this:

#include <cstdlib>
int main(){
  return 0;
}

g++ can deal with it just fine, but clang++ errors out: fatal error: 'cstdlib' file not found

Can someone explain why this happens? and what needs to be done to make this work? I expected clang++ to be a drop-on replacement for g++.

like image 875
Tarnay Kálmán Avatar asked Jul 27 '11 14:07

Tarnay Kálmán


1 Answers

Seems like your clang build is not searching the correct platform include paths. Try checking with

clang -v ...

where it is looking for headers (and check that your platform include paths are there). You might have to add additional include directories (e.g. /usr/include/c++/x.y).

You might want to take a look at the source file lib/Frontend/InitHeaderSearch.cpp, The method AddDefaultCPlusPlusIncludePaths does some distribution/gcc-version specific magic (I had to fix it for my own system once).

like image 164
Marcus Borkenhagen Avatar answered Sep 30 '22 14:09

Marcus Borkenhagen