Thread: Makefile help.

  1. #1
    Registered User Cpro's Avatar
    Join Date
    Oct 2006

    Makefile help.

    I need some help with this makefile (never made one before).

    I have a c++ program, and here is how I compile an run it on unix (works fine this way):
    g++ TestProg.cpp -lpthread -lrt

    I'm suppose to create a makefile for this. I've read through some tutorials and examples, but I can't get it to work. This is what I have now:
    prog1: TestProg.cpp
    	g++ -o prog1 TestProg.cpp -lpthread -lrt
    I don't know if this matters, but here are the headers included in TestProg.cpp:
    #include <iostream>
    #include <pthread.h>
    #include <semaphore.h>
    #include <stdio.h>
    #include <time.h>
    #include <fstream>

    When I go to use it:
    make -f makefile.txt
    It says:
    ' ake: Fatal error: Don't know how to make target 'TestProg.cpp

    Any ideas?

    IDE - Visual Studio 2005
    Windows XP Pro

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Make sure you have a space between the colon and the filename, not a tab. (It shouldn't make a difference, it doesn't on my machine, but you never know.) But it should not interpret things on the same line as the target as other targets.

    (That is to say, the makefile you have works fine for me.)

  3. #3
    Registered User Cpro's Avatar
    Join Date
    Oct 2006
    Well, I re-made the make file using vi editor instead of notepad, and it now works.

    Thank you for letting me know it worked for you. I thought I had made it incorrectly.

    IDE - Visual Studio 2005
    Windows XP Pro

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