compiling using gprof

This is a discussion on compiling using gprof within the C++ Programming forums, part of the General Programming Boards category; i am trying to modifying my makefile so that I can use the gprof profiler. Hwowever the following file doesn,t ...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    65

    compiling using gprof

    i am trying to modifying my makefile so that I can use the gprof profiler. Hwowever the following file doesn,t generate the .o executable.

    Code:
    supersonic = Impinging_jet_21
    
    OBJECTS = supersonic_ob.o flow_field.o matrix_col.o matrix_square.o matrix_functions.o matrix_derivative.o function_declarations.o output.o explicit.o Time_Step.o  Boundary.o
    
    HEADERS = Constants.h flow_field.h function_declarations.h matrix_col.h  
    
    ARCH = Linux
    CPP = g++
    CPPFLAGS = -D$(ARCH) -Wall -Wno-deprecated -pg
    LIBRARIES = -lm -lg2c
    
    supersonic: $(OBJECTS) $(HEADERS)
    	$(CPP) $(CPPFLAGS) -o $(supersonic) $(OBJECTS) $(LIBRARIES)
    
    clean:
    	rm *.o $(supersonic)
    
    .c.o:
    	gcc  -Wall -pg $<
    Last edited by Salem; 05-25-2008 at 10:33 PM. Reason: fix code tags - please review before submit

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Code:
    .c.o:
    This rule is for creating a file called ".c.o" from nothing. It's not a valid pattern rule.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    53
    Quote Originally Posted by CornedBee View Post
    Code:
    .c.o:
    This rule is for creating a file called ".c.o" from nothing. It's not a valid pattern rule.
    Are you sure about this? I thought it was a valid Makefile rule for creating .o files from .c files.

    Cheers,
    Sander

    --
    Computer Programming: An Introduction for the Scientifically inclined

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    I'm fairly sure, yes.

    There's other things wrong with the Makefile, too, such as passing the CPPFLAGS only to linking, but not to what you thought was compiling.

    You shouldn't even need the pattern rule. It's built in. Just set the CFLAGS correctly. Set LD to g++ to get C++ linking.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    53
    Quote Originally Posted by CornedBee View Post
    I'm fairly sure, yes.

    There's other things wrong with the Makefile, too, such as passing the CPPFLAGS only to linking, but not to what you thought was compiling.

    You shouldn't even need the pattern rule. It's built in. Just set the CFLAGS correctly. Set LD to g++ to get C++ linking.
    I took the liberty of looking it up:

    Suffix Rules

    Also here:

    Managing Projects with GNU Make, Third Edition (look on page 24). The book does state: "Suffix rules were make’s original means for writing general rules. GNU make includes support for suffix rules, but they are considered obsolete having been replaced by pattern rules that are clearer and more general."

    I agree with your remarks on what's broken with the Makefile, though.

    --
    Computer Programming: An Introduction for the Scientifically Inclined

  6. #6
    Registered User
    Join Date
    Nov 2007
    Posts
    19
    don't you need a intruction

    Code:
     .SUFIXXES: .o .c
    to tell make to look out for .c and .o files ?

    as to
    Code:
     .c.o
    im 110&#37; sure its a suffixe rule that "teachs" make how to create a .o file from a .c
    but you're instruction is not creating a .o file since i think you forgot the -c flag in

    Code:
    .c.o:
    	gcc  -Wall -pg $<
    should be

    Code:
    .c.o:
    	gcc  -Wall -c -pg $<
    Last edited by force of will; 05-27-2008 at 07:50 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can gprof go into each self-defined function?
    By lehe in forum C Programming
    Replies: 3
    Last Post: 03-26-2009, 10:30 PM
  2. Newbie Compiling Problem
    By Deronius in forum C++ Programming
    Replies: 3
    Last Post: 06-15-2008, 11:23 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Problem Compiling
    By Flakster in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 01:09 AM
  5. Compiling
    By Dae in forum C++ Programming
    Replies: 7
    Last Post: 06-15-2005, 01:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21