Help with a simple make file.

Hello experts.  I need to create a simple make file for these files.


main.cpp
BTree.h
BTree.cpp
TreeNode.h
TreeNode.cpp

My instructor gave us this template for the file but I am having trouble understanding it.  Could you please help me fill in the gaps?  Also are there any lines I need to add to main for the file to work properly?

Thank you Experts,

-TH

===========================================================

#compiler command
C++ = g++

# compiler flags
#-g for gdb
#-Wall to check errors and warnings
C++ FLAGS = -c -Wall

#linker command
LINKER = g++

#linker flags
LINKER-FLAGS = -o

# object files and main target

OBJS =                                                                                                   <--------- What goes here?
TARGET =                                                                                               <--------- What goes here?

$(TARGET)= $(OBJS)
      $(LINKER) $(LINKER-FLAGS) $(TARGET) $(OBJS)

clean:
      rm *.o
travishabermanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

brettmjohnsonCommented:
TARGET is the name you wish to give your program executable.
OBJS is the list of object files that will be linked together to create the program.
Compiling your source files will generate these object files:  main.o, BTree.o, TreeNode.o,
so you would define OBJS as:
OBJS = main.o BTree.o TreeNode.o

> $(TARGET)= $(OBJS)
There appears to be a minor typo here.  That '=' should probably be ':'
The line means that the target executable is dependent upon the list of object files.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
travishabermanAuthor Commented:
I have just exactly what you show there but I get this error

Makefile:24: *** commands commence before first target.  Stop.

Below is exactly what I have.  What does this error mean?



#compiler command
C++ = g++

# compiler flags
# g- for gdb
# -Wall to check errors and warnings
C++ FLAGS = -c -Wall


#linker command
LINKER = g++

#linker flags
LINKER-FLAGS = -o

# object files and main target
OBJS = main.o BTree.o TreeNode.o
TARGET = main

$(TARGET) = $(OBJS)
        $(LINKER-FLAGS) $(TARGET) $(OBJS)

clean:
        rm *.o




0
travishabermanAuthor Commented:
OOOps.. Didn't see your typo comment.. Let me try and fix that...

-TH
0
travishabermanAuthor Commented:
I have to take a break for a few so I will get back to you..

Thank you,

-TH
0
travishabermanAuthor Commented:
Tried again today and it worked great .. Thanks..

-TH
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.