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

Recommended Answers

All 2 Replies

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.