I have 2 classes: a class template list.t with definition and implementation, and ticker.h and ticker.cpp, along with a driver program, main.cpp. I want to compile main.cpp to get to main.x which uses both the ticker and list class. This is my makefile so far.
# makefile for fx project
CC = g++
CFLAGS = -g -Wall -Wextra
default: main.x
main.x: main.o ticker.o list.o
$(CC) $(CFLAGS) -o $@ main.o list.o ticker.o
list.o: list.t
$(CC) -c list.t
ticker.o: ticker.cpp
$(CC) -c ticker.cpp list.t
main.o: list.t ticker.cpp main.cpp
$(CC) -c main.cpp ticker.cpp list.t
But on executing the command make I am getting the following error:
make
g++ -c main.cpp ticker.cpp list.t
clang: warning: list.t: 'linker' input unused
g++ -c list.t
clang: warning: list.t: 'linker' input unused
g++ -g -Wall -Wextra -o main.x main.o list.o ticker.o
clang: error: no such file or directory: 'list.o'
make: *** [main.x] Error 1
List.t - (without implementations)
#ifndef LIST_T
#define LIST_T
#include <iostream>
template <typename T>
class List
{
public:
// constructors
List();
List(T);
List(const List&);
~List();
// member functions
List& operator = (const List&);
void PushFront (const T&);
void PushBack (const T&);
T PopFront();
T PopBack();
T& Front();
T& Back();
const T& Front() const;
const T& Back() const;
size_t Size() const;
bool Empty() const;
void Clear();
void Display (std::ostream&, char = '\0') const;
//private vars
private:
class Link
{
Link (const T& t) : element_(t), nextLink_(0), previousLink_(0) {};
T element_;
Link* nextLink_;
Link* previousLink_;
friend class List<T>;
};
Link* firstLink_;
Link* lastLink_;
};
I am sure this is a simple error, and I have scoured google for this error message, but I either am not fully understanding their solutions, or they are not working for me. Either way, let me know if you have a solution to this problem, or any other comments on the quality and structure of this makefile. Also any knowledge on why my flags are apparently being unused would be greatly appreciated!
Thanks!