[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

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
0
travishaberman
Asked:
travishaberman
  • 4
1 Solution
 
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
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now