954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

the most simple makefile ever

hi, this is embarrassing, for whatever reason I am getting "Don't know how to make target driver.o" whenever i type make. There is only one file named "driver.cpp" in the directory that i have to compile. I am staring at tutorials and don't understand why this won't work.

heres whats in the make file

run: driver.o
       CC -o run driver.o
driver.o: driver.cpp
       CC -c driver.cpp
kyosuke0
Newbie Poster
20 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

You do realize that you cannot use spaces. You must use tabs.

nucleon
Posting Pro in Training
478 posts since Oct 2008
Reputation Points: 163
Solved Threads: 91
 
You do realize that you cannot use spaces. You must use tabs.

yes, but you cannot use the tab key in the forum message box so i used spaces to simulate the tab. The actual make file has tabs and the newline so i know those are not the problem, also I am using sun's c++ CC compiler in linux. sorry for the confusion

kyosuke0
Newbie Poster
20 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

Does this line work if you type it into a console in the proper directory?

CC -c driver.cpp


When I used unix I only used C. Is CC (as opposed to cc) the C++ compiler?

nucleon
Posting Pro in Training
478 posts since Oct 2008
Reputation Points: 163
Solved Threads: 91
 

Does this line work if you type it into a console in the proper directory?

CC -c driver.cpp

When I used unix I only used C. Is CC (as opposed to cc) the C++ compiler?


yes if i compile the file manually it produces an executable, and yes to your second question as well, the sun studio 12 suite i believe its called

kyosuke0
Newbie Poster
20 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

I don't currently have access to Solaris ATM... alas, but perhaps it is something as simple as needing a blank line after each target:

CC = cc

run: driver.o
	CC -o run driver.o

driver.o: driver.cpp
	CC -c driver.cpp

BTW, youcan have tabs in the forum message boxes, but you have to cut and paste them in... ;) (So you can just cut and paste this code block into a file and it would work.)

The CC is a makefile macro. Sun's compiler is "cc". (I think...)

Hope this helps.

Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You