Problem with GCC

Status
Not open for further replies.

LegendBreath

Daemon Poster
Messages
511
Location
New Brunswick, Canada
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:

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
#include <stdio.h>
int main()
{
printf("Hello world!\n");
return(0);
}

Can someone help me?
 
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.
 
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.
 
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...
 
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:

/tmp/cciQwCrX.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

Can someone help me?
 
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/questions/showthread.php?s=&postid=943767#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
 
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:)
 
Status
Not open for further replies.
Back
Top Bottom