Thread: Makefile help

  1. #1
    Registered User
    Join Date
    Sep 2003

    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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Something like
    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.

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, 11: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