LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-22-2008, 09:29 AM   #1
mir_27
LQ Newbie
 
Registered: Jan 2008
Posts: 2

Rep: Reputation: 0
Help debugging C++ programs


I'm new to Linux (Kubuntu) and I'm just writing my first program (in C++) for Linux but for some reason I can't debug it.

So to test it I've tried to make a Hello World! program i plain C and this works fine, but if I change the file extension to *.cpp and compiles i again the debugger apparently can't find any symbolic information.
Whats going on?

My code:
#include <stdio.h>

int main(int argc, char *argv[])
{
printf("Hello, world!\n");;
return 1;
}

My Makefile:
CC=g++
NAME=hello
OBJS= helloworld.o
CFLAGS= -g -o0
LDFLAGS=
$(NAME): $(OBJS)
$(CC) $(CFLAGS) -o $(NAME) $(OBJS) $(LDFLAGS)

After compiling I run gdb ("gdb hello") and do a list on main.
With the *.c file this works fine and I get a listing of the source but with the *.cpp file I get this: "No line number known for main."
 
Old 01-22-2008, 07:33 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
When you compile a .c file, make uses the CFLAGS variable, when you compile a .cc file make uses the CXXFLAGS variable. Since you didn't set that g++ didn't get the -g flag when compiling.
 
Old 01-23-2008, 01:40 AM   #3
mir_27
LQ Newbie
 
Registered: Jan 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Do'h

Works now. Thankt a lot!
 
  


Reply



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
debugging a WM? kalleanka Programming 5 12-01-2007 11:44 AM
Need some debugging help Sparkfist Programming 3 06-08-2007 08:41 AM
Difference between kernel - debugging and application debugging topworld Linux - Software 2 03-30-2006 12:50 AM
Debugging Mercurius Programming 3 10-19-2005 02:59 PM
Visual Debugging and Linux Kernel Debugging Igor007 Programming 0 09-30-2005 10:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:10 PM.

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