Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-14-2012, 08:25 AM   #1
LQ Newbie
Registered: Oct 2012
Posts: 1

Rep: Reputation: Disabled
Question -g and -o in gdb

i'm newbie in linux gcc,gdb

when i make a debug.c data, and go to gcc
and put this
$gcc -g -o debugfile debug.c
$gdb debugfile
and then sentence showed up "Reading symbols from........./debugfile...done

if i use
$gcc -o debugfile debug.c
$gdb debugfile

this sentence sentence showed up
"Reading symbols from.........../debugfile...(no debugging symbols found)"

what is the causes of these different output

thank you.. sorry for bad english use
Old 10-14-2012, 10:29 AM   #2
LQ Newbie
Registered: Mar 2007
Distribution: Ubuntu
Posts: 17

Rep: Reputation: 4
That's quite simple... even if you decide to name the output file "debugfile", it doesn't actually make it be a debug file... it's just the compilation output (a binary executable).

What actually makes it "debuggable" is in fact the '-g' option:

Produce debugging information in the operating system's native format. GDB can work with this debugging information.
(taken from the kilometric gcc manual, 'man gcc')

If you add the '-g' option, debugging symbols will be added to the output file. If you don't, debugging symbols will be omitted, making your program much smaller in size, but harder to debug and reverse engineer.

Edit: Oh, and as for what debugging symbols actually are... they're little bits of extra information scattered all over the program, that help gdb figure out what assembler instruction corresponds to what line of code, what memory address corresponds to what variable name, and so on. These aren't actually needed in a program to run, but they're needed to debug it.

Last edited by Whyte; 10-14-2012 at 10:32 AM.


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
zypper install gdb, does not install the latest version of GDB TheIndependentAquarius SUSE / openSUSE 4 12-30-2010 04:00 AM
normal gdb and spec gdb for kgdb Igor007 Programming 1 09-23-2005 05:15 PM
normal gdb and spec gdb for kgdb Igor007 Linux - Newbie 1 09-23-2005 02:41 PM
gdb .. looking for 32 bit gdb.. for ia64 suse.. nkshirsagar SUSE / openSUSE 0 12-09-2004 04:02 AM
using the gdb varala_kanth Linux - Software 1 04-01-2004 07:49 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:16 AM.

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