Thread: makefile question

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    4

    makefile question

    Hello,
    I am working on an assignment for class and one of the specifications is that "the program must be divided into the five files main.c, flight.c, flight.h, passenger.c, passenger.h, as well as a makefile to create this program." I have already written the different functions needed to execute the program, I am just having a really hard time understanding how to go about creating this makefile. I have talked to the professor and other students, but its just not clicking. Could you help explain how this is supposed to work?
    Thank you so much,
    John

  2. #2
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    Did you Google "makefile" as there are lots of online tutorials for creating a makefile from scratch.

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    4
    i did, but i guess what i'm having trouble understanding is where the ' .o ' files are coming from. I was told we need to include a main.o, flight.o, and passenger.o when creating the make file, but I'm unsure of where they are coming from.

  4. #4
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    The ".o" files are object modules and are generated by modifying the behavior of the compiler with the "-c" switch.
    Lookup the man page of the C compiler on your machine and scroll down to the "-c" option - RTM.
    However, there's no need to specify how to create the ".o" files because make is smart enough to figure it out for you.

    For example the command to create a load module from three source modules would be:
    Code:
    prog:  file1.o file2.o file3.o
           cc file1.o file2.o file3.o -o prog

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by itCbitC View Post
    For example the command to create a load module from three source modules would be:
    Of course, such a simple makefile doesn't represent dependencies properly, but for the purposes of the assignment it's probably enough.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  6. #6
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    Quote Originally Posted by brewbuck View Post
    Of course, such a simple makefile doesn't represent dependencies properly, but for the purposes of the assignment it's probably enough.
    Just my 2c for what it's worth altho' a complex makefile example would have caused more confusion for the o/p, methinks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick Compilation Question
    By chacham15 in forum C Programming
    Replies: 10
    Last Post: 10-12-2008, 08:15 PM
  2. A question about an interesting Makefile
    By meili100 in forum Tech Board
    Replies: 2
    Last Post: 08-12-2008, 03:56 PM
  3. about Makefile and Macro
    By tom_mk in forum C++ Programming
    Replies: 1
    Last Post: 09-18-2003, 01:07 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Makefile Newbie: Inheritance Question
    By Ashes999 in forum C++ Programming
    Replies: 2
    Last Post: 07-10-2003, 02:34 AM