# [C++] Clang fails to compile hello world in C++



## neilms (Sep 16, 2013)

I have just compiled a simple hello world program using g++, `g++ -o hello hello.cpp`. I attempted to use the same command but invoking Clang as this is the new C++ compiler and it gives more helpful error messages. However, it outputs a stream of undefined reference messages. I can't reproduce them as my FreeBSD machine is not online. Why is this? Do I need to do special configuration to make Clang work?


----------



## fonz (Sep 16, 2013)

You might want to show more specifically what you did and what errors you got. The following works fine for me:

```
% cat > neilms.cc
#include <iostream>
using namespace std;

int
main(int argc,char **argv)
{
  cout << "Hello, world!" << endl;
  return 0;
}^D
% clang++ neilms.cc
% ./a.out
Hello, world!
```


----------



## neilms (Sep 16, 2013)

It's ok. The correct command is clang++. I had used clang only.


----------



## golpemortal (Mar 1, 2014)

It worked on me.


----------

