0

I am having a problem wih the compiling of my code.
The whole program consists of a driver program and a header file.
the problem is showing up around where it is compiling the header file. since the header file only has template functions in it and no input file i keep getting an error.

# Compiler variables
CCFLAGS = -ansi -Wall

# Rule to link object code files to create executable file
driver: driver.o heapsort.o
	g++ $(CCFLAGS) -o assign6 assign6.o heapsort.o

# Rules to compile source code files to object code
driver.o: driver.cpp heapsort.h
	g++ $(CCFLAGS) -c driver.cpp

heapsort.o: heapsort.h
	g++ $(CCFLAGS) -c

the error

$ make
g++ -ansi -Wall -c
g++: no input files
make: *** [heapsort.o] Error 1

I am reletively new to makefiles and don't know if there is a special syntax to use when there are no input files.

thank you for your help in advance

2
Contributors
2
Replies
11
Views
7 Years
Discussion Span
Last Post by dkalita
0

just wondering if the error could be that since there is no corresponding .cpp file would there even be a need to make the .h into a .o or could i just compile the driver.pp with the .h and have it work that way?

0

u need a heapsort.cpp file for creating heapsort.o
U are not giving input to the g++ command in line #13 in the Makefile.


If u have only a heapsort.h file where the whole thing is defined and u have included this file from driver.cpp then u can simply remove the heapsort.o from your Makefile making it look like

# Compiler variables
CCFLAGS = -ansi -Wall

# Rule to link object code files to create executable file
driver: driver.o
	g++ $(CCFLAGS) -o driver assign6.o heapsort.o #changed the target name

# Rules to compile source code files to object code
driver.o: driver.cpp heapsort.h
	g++ $(CCFLAGS) -c driver.cpp

OR if u want the heapsort.cpp file that would be better and that is the normal standard that u should follow. Anyway the above will also work but I suggest u to move the function definitions to heapsort.cpp file keeping the declaration only in heapsort.h file and then modifying the Makefile accordingly.


One more suggestion is that U can remove the -ansi option while compiling. It actually disables many of the features of the language.

Edited by dkalita: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.