Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a MAKE file

Status
Not open for further replies.

jl3574

Programmer
Jun 5, 2003
76
CA
Im having problem creating a make file in unix to run my C++ files.
i have two cpp file and 1 header file:
main.cpp main2.cpp header.h

i try to create a make file like this :
-----------------------------------------
calculate: main.cpp main2.cpp header.h
CC main.cpp main2.cpp -o myprogram
-------------------------------------------

but this does not work?
i create a make file b4 using just 1 cpp and 1 h and it works probably...
so can someone pls help me?
thx
 
"CC" is not normally a command.

You either want to use "cc", which is a command, or "$(CC)", which is a makefile variable that expands to a command.


Also, your makefile defeats one of the purposes of using a makefile. If you only change main2.cpp, your makefile will still recompile both your source files even though only one changed.

The correct way is to have calculate depend on your two object files, and then have each of your object files depend on its respective source file and any headers that source file includes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top