Reputation: 1858
I write a program in c++ on ubuntu (10.04)and saved it as.cc file when i complile
it wit g++ cat.cc it work fine . There is no problem the code is working fine.
but when i compile it with gcc than it show me an error which is following :/tmp/cc8aU82C.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0' collect2: ld returned 1 exit status
my code is following :
#include<stdio.h>
#include<stdlib.h>
struct man
{
int a ;
int b;
void show(int x,int y);
}
};
int main()
{
man m;
int c=50;
int d;
m.show(c,d);
return 0;
}
void man::show(int x,int y)
{
printf("%d",x);
}
Now can anybody tell me what happens wrong when i compile it with gcc?
What is the exact difference between .cpp and .cc extension if they are same than why we use them ? why do they exist ?
Upvotes: 1
Views: 541
Reputation:
If you compile with gcc, the C++ runtime is not linked in by default, so you will get linker errors like the one you are seeing. gcc and g++ will both compile files with the .cpp and .cc extensions (and others which I have forgotten) as C++, and those with a .c extension as C. But its better to be explicit and use g++ fror your C++ code and gcc for C.
Upvotes: 4
Reputation: 92271
They exist because some people have used them. :-)
When you compile with g++ you say that you want to compile the code as C++. Then the extension doesn't matter.
Upvotes: 0