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

Creating Makefile

I want to know how to create a makefile so that I dont have to type in the files I am linking together. Also is it possible to use a make file which will run two files.

I have a fraction.h file and fraction.cxx (implentation file)
I have a main.cpp file (which has the int main)
I have a main-1.cpp file which also uses (the header and implementation file)

Can the two main files be used to create one makefile

Eagles36
Newbie Poster
10 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

I want to know how to create a makefile so that I dont have to type in the files I am linking together. Also is it possible to use a make file which will run two files.

I have a fraction.h file and fraction.cxx (implentation file) I have a main.cpp file (which has the int main) I have a main-1.cpp file which also uses (the header and implementation file)

Can the two main files be used to create one makefile

You can only have one entry point in a program and that's usually the main function. If you only define main once in both main.cpp and main-1.cpp then yes you can compile them together.


Here's a short tutorial http://www.cs.umd.edu/class/spring2002/cmsc214/Tutorial/makefile.html

gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387
 

FILES=main.obj aux.obj ;;compiled files
COMPILER="x:\compiler path" ;; i use borland 5.5 under windows
build : project
project : $(FILES)
$(COMPILER) -eproject.exe $(FILES)
main.obj : main.cpp ;; main.obj depends on main.cpp
$(COMPILER) -c main.cpp
aux.obj : aux.cpp ;; when you modify the code file the obj file will be recompiled
$(COMPILER) -c aux.cpp

caut_baia
Posting Whiz
387 posts since Apr 2010
Reputation Points: 25
Solved Threads: 49
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: