![]() |
| | #1 |
| Registered User Join Date: Jan 2009
Posts: 156
| optimization and debugging options in Makefile I wonder where to put the optimization and debugging options in Makefile: linking stage or compiling stage? I am reading a Makefile: Code: ifeq ($(STATIC),yes) LDFLAGS=-static -lm -ljpeg -lpng -lz else LDFLAGS=-lm -ljpeg -lpng endif ifeq ($(DEBUG),yes) OPTIMIZE_FLAG = -ggdb3 -DDEBUG else OPTIMIZE_FLAG = -ggdb3 -O3 endif ifeq ($(PROFILE),yes) PROFILE_FLAG = -pg endif CXXFLAGS = -Wall $(OPTIMIZE_FLAG) $(PROFILE_FLAG) $(CXXGLPK) test: test.o rgb_image.o $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) Makefile.depend: *.h *.cc Makefile $(CC) -M *.cc > Makefile.depend clean: \rm -f absurdity *.o Makefile.depend TAGS -include Makefile.depend Thanks and regards! |
| lehe is offline | |
| | #2 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| Given that optimization happens only at compilation and not at linking, and that debugging information happens only at compilation and not at linking, I'm not sure why you're even asking the question. |
| tabstop is offline | |
| | #3 |
| Registered User Join Date: Jan 2009
Posts: 156
| Thanks! I am learning to use someone's Makefile So it is not use to include CXXFLAG in linking as in his Makefile Code: test: test.o rgb_image.o $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) |
| lehe is offline | |
| | #4 | |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,381
| Quote:
Code: ifeq ($(STATIC),yes) LDFLAGS=-static -lm -ljpeg -lpng -lz $(PROFILE_FLAG) else LDFLAGS=-lm -ljpeg -lpng $(PROFILE_FLAG) endif
__________________ "Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot | |
| brewbuck is offline | |
| | #5 |
| Registered User Join Date: Jan 2009
Posts: 156
| Thank you! Is it possible to point me to some references of which option is done in which stage? Thanks! |
| lehe is offline | |
| | #6 |
| Frequently Quite Prolix Join Date: Apr 2005 Location: Canada
Posts: 7,629
| Well, you could try the manual. It has some categories of options, but it's pretty detailed. I guess the best way to understand it is to know what debugging information is. Debugging information is just extra information that the compiler adds to the program so that you can tell which line of C code an assembly instruction corresponded to, for example. The linker doesn't care about debugging information; all it does is take the already-existing object files and link them together. Its primary job is to figure out what external symbols refer to; it has to resolve all references in one object file to somewhere else, so that a coherent executable is formed in the end.
__________________ dwk Seek and ye shall find. quaere et invenies. "Simplicity does not precede complexity, but follows it." -- Alan Perlis "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra "The only real mistake is the one from which we learn nothing." -- John Powell Other boards: DaniWeb, TPS Unofficial Wiki FAQ: cpwiki.sf.net My website: http://dwks.theprogrammingsite.com/ Projects: codeform, xuni, atlantis, etc. New project: nort |
| dwks is offline | |
![]() |
| Tags |
| compile, debug, link, makefile, optimization |
| Thread Tools | |
| Display Modes | |
|