LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   gcc ld error. Undefined reference (https://www.linuxquestions.org/questions/linux-software-2/gcc-ld-error-undefined-reference-287215/)

redness 02-07-2005 05:45 AM

gcc ld error. Undefined reference
 
Hi Peoples

I was trying to compile a standard cpp file. (just a simple printf line of code). And gcc came up with the following error

user@comp:~/dir$ gcc -o a test.cpp
/tmp/ccIip5Jd.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

Code:

#include <stdio.h>

int main(void)
{
  printf("Hello");
  return 0;
}

Now I dont think this used to happen...however it happens on two machines, both with slackware 10 installed, one with the standard kernel, one with 2.6.10.

cc does not work either (same error)

g++ does work...but I would like to know wots wrong with gcc. (as far as I can tell programs have been compiling from source properly)

Any Help would be much appreciated

Redness

__J 02-07-2005 11:04 AM

I think it's because gcc determines file type by extension. you are calling the c compiler to compile c++ code (at least the compiler thinks it is because of the cpp extension) and it will try to link the c++ libs into the executable even though it's clearly c code. try to rename it test.c. does it compile cleanly if you do?

redness 02-07-2005 03:02 PM

it does!

however, how come gcc cant compile c++? i didn't have the same problem on another comp using gcc

redness

__J 02-07-2005 03:10 PM

g++ is not a compiler, but a shell script that sets up gcc in a different way. when gcc sees the .cpp extension, I imagine it tries to compile it but since it was not invoked with the g++ shell script is not able to do everything it needs to.

Again, I'm no expert on this, and I could be wrong.

redness 02-08-2005 02:01 AM

oh ok thanks, ill just make do.

redness


All times are GMT -5. The time now is 09:12 AM.