Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 12-29-2004, 08:58 AM   #1 (permalink)
 
Ultra Techie

Join Date: Dec 2004

Location: New Brunswick, Canada

Posts: 511

LegendBreath

Send a message via MSN to LegendBreath
Default Problem with GCC

Hi,
I have a problem with GCC (the lastest version).
When I'm trying to pass the command "gcc HELLO.C -o HELLO" to compile the source code "HELLO.C" it's give me this error:

Quote:
HELLO.C:6:2: warning: no newline at end of file
/tmp/ccOzGery.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
and here is what there is in HELLO.C
Quote:
#include <stdio.h>
int main()
{
printf("Hello world!\n");
return(0);
}
Can someone help me?
__________________
LegendBreath is offline  
Old 12-29-2004, 01:40 PM   #2 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default

When you compile, type gcc -Wall Hello.c -o HELLO

This will turn all the warnings on. This should give you a better hint as to what's wrong in your program.
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 12-29-2004, 01:42 PM   #3 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default

Also, just for s's and g's, try putting an extra return at the end of your source file.

I'm not sure why it's not putting a newline character there, but eh. Sometimes you have to play the compiler's game.
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 12-29-2004, 01:43 PM   #4 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default

The last thing I might try, although you shouldn't need to do this any more is putting void in for your call to main.

int main(void)
{etc...
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 12-29-2004, 02:56 PM   #5 (permalink)
 
Ultra Techie

Join Date: Dec 2004

Location: New Brunswick, Canada

Posts: 511

LegendBreath

Send a message via MSN to LegendBreath
Default

I've insered a new line at the end and now it doesnt say "HELLO.C:6:2: warning: no newline at end of file" anymore. But, it's still says:

Quote:
/tmp/cciQwCrX.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
Can someone help me?
__________________
LegendBreath is offline  
Old 07-07-2005, 06:25 PM   #6 (permalink)
 
Newb Techie

Join Date: Jul 2005

Posts: 12

mikhael

Default

Guys, I had the very same problem,trying to learn C by book and and had a very same message. I know whats wrong, below is a link to discussion and , just in case, text of the answer to the problem.
http://www.linuxquestions.org/questi...767#post943767

QUOTE
Re: trouble in functions ( post #3)
quote:
Originally posted by Hamid Moradmand
# gcc -o findmax findmax.cpp
/tmp/ccWOi10S.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

In UNIX/Linux filename extension like .doc .txt .c do not have as much meaning as in Windows/DOS, but the compiler is one of the exceptions: gcc does watch the filename "extensions" (called "file name suffix" in the gcc man page).

Some examples: (there are more. Read "man gcc" for more info on this)

For plain C source files: xxxx.c
For C++ source files: xxxx.C xxxx.cpp xxxx.cc or xxxx.cxx
For header files: xxxx.h

What happens in your case is that you have a C program with an C++ extension: "findmax.cpp", and you try to compile it with the C compiler ("gcc").

Two solutions:

1) Compile your program with the C++ compiler:
g++ -o findmax findmax.cpp

2) Rename your source file to "findmax.c".

I'd recommend the second one, as your program is C code, not a C++.
END OF QUOTE

It works for me
mikhael is offline  
Old 07-09-2005, 02:20 AM   #7 (permalink)
 
Junior Techie

Join Date: Jan 2005

Posts: 94

charles@pcfix

Default

I copied you code and compiled it with no problems.
__________________
Charles

Visit my Site
http://www.pc-fix.info
charles@pcfix is offline  
Old 07-09-2005, 02:23 AM   #8 (permalink)
 
Junior Techie

Join Date: Jan 2005

Posts: 94

charles@pcfix

Default

You are not typing the comand correctly.
Try this: gcc -o HELLO HELLO.c
__________________
Charles

Visit my Site
http://www.pc-fix.info
charles@pcfix is offline  
Old 07-12-2005, 08:14 PM   #9 (permalink)
 
Newb Techie

Join Date: Jul 2005

Posts: 12

mikhael

Default

gcc HELLO.c -o HELLO works fine, the error is typing the capital C instead of small c. The capital C is for C++. I had the same mistake, misprint in the book, nearly byte my keyboard
mikhael is offline  
 
Closed Thread

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On