Makefile help

This is a discussion on Makefile help within the C++ Programming forums, part of the General Programming Boards category; suppose i have mainprog.cpp that uses program.h. how do i create a makefile and how do i run it?...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    4

    Makefile help

    suppose i have mainprog.cpp that uses program.h.
    how do i create a makefile and how do i run it?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,489
    Something like
    Code:
    mainprog.o : mainprog.cpp program.h
    	$(CXX) -c mainprog.cpp
    
    prog : mainprog.o
    	$(CXX) -o prog mainprog.o
    Note the indent before each $CXX is a real tab character, not spaces. This will catch you out.

    You save this file as Makefile, and you run it by typing make at the command line prompt.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile Problem: None rule to make target
    By chris24300 in forum Linux Programming
    Replies: 25
    Last Post: 06-17-2009, 09:45 AM
  2. Building a project using a Makefile
    By starcatcher in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2008, 10:50 PM
  3. unix makefile won't work but works in Dev C++
    By jk1998 in forum C++ Programming
    Replies: 1
    Last Post: 06-09-2007, 03:54 PM
  4. makefile blues....
    By WaterNut in forum C Programming
    Replies: 6
    Last Post: 05-30-2005, 08:22 PM
  5. Need help with Makefile
    By xshapirox in forum C++ Programming
    Replies: 14
    Last Post: 09-28-2004, 03:32 PM

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