* [KJ] Makefile question
@ 2007-06-19 0:32 tiob lew
2007-06-19 1:22 ` Matthew Wilcox
0 siblings, 1 reply; 2+ messages in thread
From: tiob lew @ 2007-06-19 0:32 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1.1: Type: text/plain, Size: 2977 bytes --]
Hi,
I have a problem about Makefile and gdb. I write a program and if I compile
the files by the following command:
g++ -g scheduler.cc generate_task.cc schedule_task.cc energy_storage.cc -o
energy_harvesting_prog
I can debug the program as usual with command " gdb energy_harvesting_prog"
However, when I use Makefile , shown in Appendix 2, for compiling the
program, it seems Makefile automatically ignore option "-g", shown in
Appendix 3.
Accordingly, I can not debug the program properly, and the error
information is shown in Appendix 0.
How should I modify Makefile so that the program could be debugged by gdb.
Thank you very much.
############################## Appendix 0
############################################
$gdb energy_harvesting_prog
GNU gdb Red Hat Linux (6.3.0.0-1.132.EL3rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...(no debugging symbols
found)
Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) run
Starting program: ~/energy_harvesting_prog
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
############################## Appendix 1
############################################
GCC version
$gcc --version
gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-58)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
For the reference, I also post the Makefile and the prompt information after
running command "make".
############################## Appendix 2
############################################
Makefile
CC = g++
LD = g++
CFLAGS = -g -Wall
LDFLAGS = -g
SRCS = scheduler.cc generate_task.cc schedule_task.cc energy_storage.cc
OBJS = scheduler.o generate_task.o schedule_task.o energy_storage.o
PROG = energy_harvesting_prog
RM = /bin/rm -f
$(PROG): $(OBJS)
$(LD) $(LDFLAGS) $(OBJS) -o $(PROG)
$@: $<
$(CC) $(CFLAGS) -c $<
clean:
$(RM) $(OBJS) $(PROG)
############################## Appendix 3
#############################################
### output after I run make
$ make
g++ -c -o scheduler.o scheduler.cc
g++ -c -o generate_task.o generate_task.cc
g++ -c -o schedule_task.o schedule_task.cc
g++ -c -o energy_storage.o energy_storage.cc
g++ -g scheduler.o generate_task.o schedule_task.o energy_storage.o -o
energy_harvesting_prog
##################################################################################################
[-- Attachment #1.2: Type: text/html, Size: 4275 bytes --]
[-- Attachment #2: Type: text/plain, Size: 187 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [KJ] Makefile question
2007-06-19 0:32 [KJ] Makefile question tiob lew
@ 2007-06-19 1:22 ` Matthew Wilcox
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2007-06-19 1:22 UTC (permalink / raw)
To: kernel-janitors
On Mon, Jun 18, 2007 at 08:32:54PM -0400, tiob lew wrote:
> I have a problem about Makefile and gdb.
This is completely off-topic for this list.
> How should I modify Makefile so that the program could be debugged by gdb.
However, I can see what your problem is. Your rule:
> $@: $<
> $(CC) $(CFLAGS) -c $<
is never being invoked.
Just set CXXFLAGS instead of CFLAGS, and the predefined implicit rule
will take care of it.
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-06-19 1:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-19 0:32 [KJ] Makefile question tiob lew
2007-06-19 1:22 ` Matthew Wilcox
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.