I have three files that I need to link using a makefile but I continuously get undefined function errors and I cannot figure out why
Makefile

# sectool.make
CC = g++
CFLAGS = -c

all: sectool

sectool: Transposition.o Substitution.o System.o 
	${CC} -o sectool Transposition.o Substitution.o System.o 

System.o: System.cpp Transposition.cpp Substitution.cpp Substitution.h Transposition.h
	${CC} ${CFLAGS} System.cpp 

Substitution.o: Substitution.cpp Substitution.h 
	${CC} ${CFLAGS} Substitution.cpp 
 
Transposition.o: Transposition.cpp Transposition.h
	${CC} ${CFLAGS} Transposition.cpp 
 
clean: 
	rm *.o sectool 

# END OF MAKE FILE

System.cpp

#include <cctype>
#include <iostream>
#include <string>
#include <climits>
#include <fstream>
#include "Sub.h"
#include "Trans.h"

using namespace std;

class System{
public:
string convertUp(string& lower)
{
	int i  =0;
	string upper;
	while (i < lower.length())
	{
		if (islower(lower[i]))
			{
				 upper.push_back(toupper(lower[i]));
			}
		else if (isupper(lower[i]))
			{
				upper.push_back(lower[i]);
			}
		i++;
	}
	return upper;
}

bool isEnc()
{
	bool isEnc = false;
	if (flags[1] == "-e")
	{
	isEnc = true;
	}
	return isEnc; 
}
bool isDec()
{
	bool isDec = false;
	if (flags[1] == "-d")
	{
		isDec = true;
	}
	return isDec;
}
bool isSub()
{
	bool isSub = false;
	if (flags[2] == "-2")
	{
		isSub = true;
	}
	return isSub;
}
bool isTran()
{
	bool isTran = false;
	if (flags[2] == "-1")
	{
		isTran = true;
	}
	return isTran;
}
void setFlags(char *newFlags[], int size)
{
	for (int i = 0; i < size; i++)
	{
		flags[i] = newFlags[i];
	}
}
string getKey()
{
	string key;
	cout << "\nEnter Key: ";
	cin >> key;
	key = convertUp(key);
	return key;
}
string getName()
{
	string name;
	cout << "\n Enter a new file name: ";
	cin >> name;
	return name;
}
string getText(string& fileName)
{
	string text = "test";
	/*ifstream file;
	file.open(fileName);
	if (file.is_open())
	{
		while (!file.eof())
		{
			getline(file, text);
		}
	}	
	else 
	{
		cout << "File could not be found. \n";
	}*/	
	return text;
}
void Menu()
{
	string fileName = flags[3];
	string text = getText(fileName);
	string name = getName();
	string key = getKey();
	if (isTran())
	{
		Transposition t(key);
		if (isEnc())
		{
			string encText = t.encrypt(text);
		}
		else if (isDec())
		{
			string decText = t.decrypt(text);
		}
	}
	else if (isSub())
	{
		Substitution s(key);
		if (isEnc())
		{
			string encText = s.encrypts(text);
		}
		else if (isDec())
		{
			string decText = s.decrypts(text);
		}
	}	
}

private:
char *flags[99];

};

int main(int argc, char *argv[]){
char *flags[argc];
System test;
test.setFlags(argv, argc);
string text = "tEst";
string a = test.convertUp(text);
cout << "lower case: " << text << endl;
cout << "upper case: " << a << endl;
string key;
key = test.getKey();
cout << key << endl;
test.Menu();}

Transposition.h

#ifndef TRANS_H
#define TRANS_H
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string>

using namespace std;

class Transposition{
private:
	string key, pText, eText;
public:
	Transposition();
	Transposition(string newKey);
	string encrypt(string& plainText);
	string decrypt(string& encText);
	int getColumn(string newKey);
};
#endif

Substitution.h

#ifndef SUB_H
#define SUB_H
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string>

using namespace std;

class Substitution{
private:
	string keys, pTexts, eTexts;
public:
	Substitution();
	Substitution(string newKey);
	string encrypts(string& plainText);
	string decrypts(string& encText);
};
#endif

the output I get when I run the makefile

make -f sectool.make all
g++ -o sectool Transposition.o Substitution.o System.o 
System.o: In function `System::Menu()':
System.cpp:(.text._ZN6System4MenuEv[System::Menu()]+0x11d): undefined reference to `Transposition::encrypt(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
System.cpp:(.text._ZN6System4MenuEv[System::Menu()]+0x155): undefined reference to `Transposition::decrypt(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
System.cpp:(.text._ZN6System4MenuEv[System::Menu()]+0x20f): undefined reference to `Substitution::encrypts(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
System.cpp:(.text._ZN6System4MenuEv[System::Menu()]+0x247): undefined reference to `Substitution::decrypts(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
collect2: ld returned 1 exit status
make: *** [sectool] Error 1

You need to define your "System" class like you did the other two; a header file to declare the class, and an implementation file to define the methods of the class. Your methods for "System" then need to be implemented like:

void System::Menu()
{
   // Code
}

string System::convertUp(string& lower)
{
   // Code
}

etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.