why the code cant work?

I'am new in C programming in UNIX.
the code is as following:
---------------------------------
#include<stdio.h>
#include<unistd.h>

int main()
{
printf("pid=%d\n",getpid());
return 0;
}
----------------------------------
when I compile it(gcc) it output errors:

Undefined first referenced
symbol in file
__gxx_personality_v0 /var/tmp//ccLAMPgc.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status

I dont know why,please help me. thanks.

'gcc' has many options. What is the exact gcc command that you are using ? You may also try using 'g++' and see if that changes anything. I've had similar problems happen when multiple instances of gcc were installed on the same machine and the linker was not linking in the correct libraries.

I tried that code in several c compilers. I can't get it to fail. Your compiler must be broken somehow.

I tried g++ and it works.
It seems that my gcc have broken:(

Thanks you all:)

What is the name of your file ? The undefined symbol looks like a name mangled C++ symbol. g++ is really just gcc which is invoked with some flags to tell gcc to compile using C++. However, gcc will also use the file name to decide whether or not to compile as C++ (.C or .cc --> C++). So, your file may have been getting compiled as C++ but trying to link with the non-C++ standard library.