I am trying to make a makefile in UNIX for 7 files (main.cpp, size.h, size.cpp,
ID: 3828286 • Letter: I
Question
I am trying to make a makefile in UNIX for 7 files (main.cpp, size.h, size.cpp, history.h, history.cpp, extra.h, and extra.cpp). I get an error that says "cc1plus: error: unrecognised debug output level "co". Can someone help me figure out what this error means and how I need to fix it. I also attached the criteria of the assignment.
# Macro defined as CC
CC = g++
DIR = /home/majors/ison/Assignment7/lib
# Compile only flags. Turns on the interactive debugger. Specifies the compile only option. Compiled with the -c option before linking.
CFLAGS = -gco
# Link flags. Turns on the interactive debugger. Compiled with the -c option before linking.
LFLAGS = -gc -I$(DIR) # Allows for system level files to be placed in the current directory.
main: main.cpp extra.cpp history.cpp size.cpp
$(CC) $(LFLAGS) -o main main.cpp extra.cpp history.cpp size.cpp # The flag -o main makes the output main.
main.cpp: size.h extra.h
$(CC) $(CFLAGS) main.cpp size.h extra.h
extra.cpp: extra.h
$(CC) $(CFLAGS) extra.cpp extra.h
history.cpp: history.h
$(CC) $(CFLAGS) history.cpp history.h
size.cpp: size.h
$(CC) $(CFLAGS) size.cpp size.h
# Cleans up any temporary files after the compile and link.
clean:
rm -rf *o main
Explanation / Answer
Hi
The error is due to LFLAGS which uses to link the system level files in current project directory.
Please find the modified Makefile
# Macro defined as CC
CC = g++
DIR = /home/majors/ison/Assignment7/lib
# Compile only flags. Turns on the interactive debugger. Specifies the compile only option. Compiled with the -c option before linking.
CFLAGS = -gco
# Link flags. Turns on the interactive debugger. Compiled with the -c option before linking.
LFLAGS = -g -I$(DIR) # Allows for system level files to be placed in the current directory.
main: main.cpp extra.cpp history.cpp size.cpp
$(CC) $(LFLAGS) -o main main.cpp extra.cpp history.cpp size.cpp # The flag -o main makes the output main.
main.cpp: size.h extra.h
$(CC) $(CFLAGS) main.cpp size.h extra.h
extra.cpp: extra.h
$(CC) $(CFLAGS) extra.cpp extra.h
history.cpp: history.h
$(CC) $(CFLAGS) history.cpp history.h
size.cpp: size.h
$(CC) $(CFLAGS) size.cpp size.h
# Cleans up any temporary files after the compile and link.
clean:
rm -rf *o main
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.