I need HELP ASAP

I am trying to compile my makefile but I get this error:

g++ --static Main.cpp InternalTools.cpp ExternalTools.cpp InternalData.h InternalTools.h -o ZombieApocalypse
/tmp/ccPWF5fM.o: In function `main':
Main.cpp:(.text+0x62): undefined reference to `readZombieFile(char*, Zombie*, int, int&)'
collect2: ld returned 1 exit status
make: *** [ZombieApocalypse] Error 1


Here are all my .cpp and .h files
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "InternalTools.h"

int main()
{
	char path[12] = "Zombies.dat";
	Zombie zombies[100];
	int zombieCount;
	bool success = readZombieFile(path, zombies, 100,zombieCount);
	
// Once you've implemented the play() function, you can call it from here
	// play();
	return 0;
}



InternalData.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef H_GUARD
#define H_GUARD
#include <string>
using namespace std;

struct Zombie
{
	int health;
	int distance;
};

struct Weapon
{
	string name;
	int damage;
	int ammunition;
};
#endif 


InternalTools.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "InternalTools.h"
#include <fstream>
using namespace std;

// Add your functions and implementations here
bool zeadZombieFile(char path [], Zombie zombies [], int maxCount, int &zombieCount)
{
	bool status = false;
	int index;
	ifstream dataFile;
	dataFile.open(path);
	if(!dataFile)
	{
		dataFile.close();
		status = false;
		return status;
	}
	else if (!(dataFile >> zombieCount))
	{
		dataFile.close();
		status = false;
		return status;
	}
	else if(dataFile.eof() == 1)
	{
		dataFile.close();
		status = false;
		return status;
	}
	else if(zombieCount > maxCount)
	{
		for(index = 0; index < maxCount;index++)
		{
			dataFile >> zombies[index].health;
			dataFile >> zombies[index].distance;
		}
		dataFile.close();
		status = false;
		return status;
	}
	else
	{
		for(index = 0;index < zombieCount;index++)
		{
			dataFile >> zombies[index].health;
			dataFile >> zombies[index].distance;
		}
		dataFile.close();
		status = true;
		return status;
	}

}


InternalTools.h
***I AM NOT TO CHANGE OR ADD ANY CODE IN THIS HEADER FILE***
1
2
3
4
5
6
7
#include <string>
#include "InternalData.h"

using namespace std;

// Task 2
bool readZombieFile(char path[], Zombie zombies[], int maxCount, int &zombieCount);



HERE IS MY MAKEFILE
ZombieApocalypse : Main.cpp InternalTools.cpp
g++ --static Main.cpp InternalTools.cpp -o ZombieApocalypse

pLEASE HELP
Last edited on
Can someone please help. I think its my makefile
I didn't check your code so far but i suggest using an IDE like Netbeans, Eclipse or CodeBlocks, just to name some, because they automatically generate the make-files ...
InternalTools.cpp implements bool zeadZombieFile(char path [], Zombie zombies [], int maxCount, int &zombieCount) and in InternalTools.h you have bool readZombieFile(char path[], Zombie zombies[], int maxCount, int &zombieCount)

The fix is obvious.
You have a typo in InternalTools.hpp. zeadZombieFile should be readZombieFile.
Topic archived. No new replies allowed.