Re: no Hello World!!



rwittenberg@xxxxxxxxxxxxxxx wrote:
I wrote a program using the Fedora Core 6 linux enviroment as follows:

#include <stdio.h>

int main()

You better make that

int main( void )

since your main() function doesn't take any arguments.

{
double number;

That line isn't needed at all, 'number' is never used anywhere.

printf("\nHello World");
return 0;
}

I compile this with "gcc -lm hello_world.c"

You should always put the libraries at end of the compile command.
And the program you will get out of this will be called 'a.out'.
If you want a program called 'hello_world' then you would need

gcc -o hello_world hello_world.c -lm

(but since you don't need antyhing from the math library you
can as well drop the '-lm' bit).

On running it on my debian woody system my program crashes with the
message "Floating Point Exception"

(gdb) run
Starting program: ~/hello_world.c

According to the command line above 'hello_world.c' is a C source
file, not a program. I don't really believe that this is the out-
put of gdb if you ask it to "run" a C source file. It will instead
tell you that you didn't specify an executable program

(no debugging symbols found)

No wonder since you didn't tell the compiler to include debugging
symbols into the executable - you would need the additional com-
piler flag '-g' for that.

Program received signal SIGFPE, Arithmetic exception.
0xb7fad5d1 in ?? ()
(gdb) bt
#0 0xb7fad5d1 in ?? ()
#1 0x00000000 in ?? ()
#2 0x00000000 in ?? ()
..............................
..............................
..............................

There are too many things that look as if your don't describe
what you have really done, so I can't come up with any reason-
able explanation. Did you try to run your 'a.out' program?

Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.



Relevant Pages

  • Re: invoking gdb from within an application script
    ... I want to debug a C ... program which is being called from inside an application script. ... But since it does not stop at gdb ... command does not function as the source file path at the development ...
    (comp.unix.shell)
  • Re: Cant open the source file with GDB
    ... > I wanted to try using GDB in XEmacs and every time the GDB tries to ... > stop on a break point in a source file it outputs in the MiniBuffer: ... Windows build, is it a Cygwin build, is it perhaps a Unix with a profoundly ... confused pathname parsing library in XEmacs? ...
    (comp.emacs.xemacs)
  • Re: How can I get line number displayed with dgb in emacs?
    ... how can I display the line number in my gdb ... > session in emacs. ... >> pointer movement in the source file according to the execution of the code. ...
    (comp.emacs.xemacs)
  • Cant open the source file with GDB
    ... I wanted to try using GDB in XEmacs and every time the GDB tries to ... stop on a break point in a source file it outputs in the MiniBuffer: ... Prev by Date: ...
    (comp.emacs.xemacs)