LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 02-07-2005, 06:45 AM   #1
redness
Member
 
Registered: Dec 2004
Distribution: Slackware 10
Posts: 40

Rep: Reputation: 16
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
 
Old 02-07-2005, 12:04 PM   #2
__J
Senior Member
 
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
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?
 
Old 02-07-2005, 04:02 PM   #3
redness
Member
 
Registered: Dec 2004
Distribution: Slackware 10
Posts: 40

Original Poster
Rep: Reputation: 16
it does!

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

redness
 
Old 02-07-2005, 04:10 PM   #4
__J
Senior Member
 
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
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.
 
Old 02-08-2005, 03:01 AM   #5
redness
Member
 
Registered: Dec 2004
Distribution: Slackware 10
Posts: 40

Original Poster
Rep: Reputation: 16
oh ok thanks, ill just make do.

redness
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Undefined reference error jacques83 Programming 20 04-11-2013 08:23 AM
Undefined reference error in MD5_Init() jacques83 Programming 3 11-13-2005 10:41 PM
gcc linking: undefined reference to just about everything shabbychef Programming 7 09-09-2005 09:42 PM
undefined reference error Quest101 Programming 3 01-01-2005 01:27 PM
Undefined reference error using gcc with Redhat Linux 9.0 armesk Programming 2 08-28-2003 07:42 AM


All times are GMT -5. The time now is 03:23 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration