C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 10-22-2008, 07:33 PM   #1
Registered User
 
Cpro's Avatar
 
Join Date: Oct 2006
Posts: 146
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
./a.out

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:
Code:
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?

Thanks.
__________________
IDE - Visual Studio 2005
Windows XP Pro
Cpro is offline   Reply With Quote
Old 10-22-2008, 08:00 PM   #2
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,862
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.)
tabstop is offline   Reply With Quote
Old 10-22-2008, 08:18 PM   #3
Registered User
 
Cpro's Avatar
 
Join Date: Oct 2006
Posts: 146
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.

Thanks.
__________________
IDE - Visual Studio 2005
Windows XP Pro
Cpro is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 06:12 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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