makefile

I want to have debugging option. Even while linking I have given -g option but I am not getting line numbers. What should I do? Is it given compilation time of linking time?

If to be given at compilation time. I have to explicitely write
g++ -g -c <files>

Is their any efficient way to do that?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
main: Main.o Time.o Atomic.o ANode.o LNode.o Thread.o QNode.o UnboundedQueue.o
    g++ -o main Main.o Time.o Atomic.o ANode.o LNode.o Thread.o QNode.o UnboundedQueue.o -pthread -g -Wall

Main.o: Main.cpp
    g++ -c Main.cpp

Thread.o: Thread.h

Time.o: Time.h

Atomic.o: Atomic.h

ANode.o: Atomic.o ANode.h

LNode.o: LNode.h

QNode.o: Atomic.o QNode.h

UnboundedQueue.o: UnboundedQueue.h

clean:
    rm *.o main
g++ -c -g foo.cpp -o foo.o

You need the -g option on the compile step as well as the link step.
You could add -g as an option at the top of the makefile and insert the options into each of your g++ calls...just do some searches online for examples.

Something like:
1
2
3
4
FLAGS = -g

main: Main.o Etc.o
    g++ ${FLAGS} -o main Main.o Etc.o
What I meant was. The way I have written the makefile right now is that I don't need to explicitely write the command(g++ -c <file>) for generating object files. But If I require debugging option. I have to write the command explicitely.

Is there any way to use this shorthand notation and still have debugging option?
Topic archived. No new replies allowed.