This is a discussion on Gcc and Core dump within the Linux General forums, part of the Linux Forums category; Hi all I am a C++ programmer, and very new in Linux and using gcc. When I am compiling my ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi all
I am a C++ programmer, and very new in Linux and using gcc. When I am compiling my program, I am getting error and core dump. I was wondering if there is any flag or some way in gcc that make it possible too see what the error is, and where it is located. or some more information about the error. Thanks in advance Sam |
|
|||
|
Sam wrote:
> Hi all > > I am a C++ programmer, and very new in Linux and using gcc. When I am > compiling my program, I am getting error and core dump. I was wondering if > there is any flag or some way in gcc that make it possible too see what the > error is, and where it is located. or some more information about the error. If you compile your code with the -g option (for debug), you can run the program in a debugger (like ddd for example) and will show you where the problem is. Alternatively, you can load the program into a debugger with the core file and find out the state of the program at the point of failure. Pual |
|
|||
|
On Thu, 11 Sep 2003 10:37:54 -0700, Sam staggered into the Black Sun and
said: > I am a C++ programmer, and very new in Linux and using gcc. When I am > compiling my program, I am getting error and core dump. If you get an error and a core dump while you're *compiling* a program, you've found a bug in gcc. You meant "I get an error and a core dump when I *run* the program I've compiled," right? > I was wondering if there is any flag or some way in gcc that make it > possible too see what the error is, and where it is located. or some > more information about the error. gcc doesn't really deal with runtime errors. You need to pass gcc the -g option to tell it to compile your program with additional debugging information. Then when your program crashes and produces a core dump, you need to load that core dump into a debugger. The "standard" debugger is gdb, but you can also use xxgdb or something like kdevelop (an interactive development environment similar to VC++.) You'd do something like: gcc -g -o myprogram myprogram.c ../myprogram (Segmentation fault - core dumped) gdb -s myprogram core (gdb) list (gdb) backtrace ....and you'll see a listing around the line where your program failed, and a backtrace of all the previously called functions. There is extensive online documentation for gdb; Google for "gdb tutorial". gdb also integrates with Emacs rather well (hmm, if it integrates with vim in similar ways, I'd be stylin' ....) HTH, -- Matt G|There is no Darkness in Eternity/But only Light too dim for us to see Brainbench MVP for Linux Admin / http://www.brainbench.com / "He is a rhythmic movement of the -----------------------------/ penguins, is Tux." --MegaHAL |
|
|||
|
And, by the way, if you're writing C++ code, compile with g++.
On Thu, 11 Sep 2003 21:41:09 +0100, Paul Black wrote: > Sam wrote: >> Hi all >> >> I am a C++ programmer, and very new in Linux and using gcc. When I am >> compiling my program, I am getting error and core dump. I was wondering if >> there is any flag or some way in gcc that make it possible too see what the >> error is, and where it is located. or some more information about the error. > > If you compile your code with the -g option (for debug), you can run the > program in a debugger (like ddd for example) and will show you where the > problem is. Alternatively, you can load the program into a debugger with > the core file and find out the state of the program at the point of failure. > > Pual |
|
|||
|
Dances With Crows wrote:
> On Thu, 11 Sep 2003 10:37:54 -0700, Sam staggered into the Black Sun and > said: > >>I am a C++ programmer, and very new in Linux and using gcc. When I am >>compiling my program, I am getting error and core dump. > > > If you get an error and a core dump while you're *compiling* a program, > you've found a bug in gcc. That could also mean a hardware problem, especially DRAM. You can find a DRAM tester here. http://www.memtest86.com -- My projects: http://tcron.sourceforge.net http://fftv.sourceforge.net http://www.csie.nctu.edu.tw/~cp76/gcb |
|
|||
|
Thank you very much for your help every body
/Sam "Vampire at Wicked Empire" <vampire001@localhost.localdomain> wrote in message news:bjrisr$89o$1@news.seed.net.tw... > Dances With Crows wrote: > > On Thu, 11 Sep 2003 10:37:54 -0700, Sam staggered into the Black Sun and > > said: > > > >>I am a C++ programmer, and very new in Linux and using gcc. When I am > >>compiling my program, I am getting error and core dump. > > > > > > If you get an error and a core dump while you're *compiling* a program, > > you've found a bug in gcc. > > That could also mean a hardware problem, especially DRAM. > > You can find a DRAM tester here. > http://www.memtest86.com > > > -- > My projects: > http://tcron.sourceforge.net > http://fftv.sourceforge.net > http://www.csie.nctu.edu.tw/~cp76/gcb > |