Hey I am having a problem when I am compiling my makefile. This is the error that I am having and cannot see what is wrong with my code. I am using multiple header files
/Project/Project$ make
g++ -static InternalTools.cpp ExternalTools.cpp Main.cpp -o ZombieApocalypse
In file included from InternalTools.h:2:0,
from InternalTools.cpp:1:
InternalData.h:27:60: error: ‘readZombieFile’ was not declared in this scope
In file included from ExternalTools.h:1:0,
from ExternalTools.cpp:1:
InternalData.h:27:60: error: ‘readZombieFile’ was not declared in this scope
In file included from InternalTools.h:2:0,
from Main.cpp:1:
InternalData.h:27:60: error: ‘readZombieFile’ was not declared in this scope
make: *** [ZombieApocalypse] Error 1
Hear is all my code
HEADER FILE InternalData.h
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
|
#ifndef H_GUARD
#define H_GUARD
#include <string>
using namespace std;
const int size = 100;
const int pathSize = 12;
struct Zombie
{
int health;
int distance;
};
struct Weapon
{
string name;
int damage;
int ammunition;
};
char path[pathSize] = "Zombies.dat";
Zombie zombies[size];
int zombieCount;
bool success = readZombieFile(path,zombies,size,zombieCount);
#endif
|
HEADER FILE InternalTools.h
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);
|
FILE 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
|
#include "InternalTools.h"
#include<fstream>
// Add your functions and implementations here
bool readZombieFile(char path[], Zombie zombies [], int maxCount, int zombieCount)
{
bool fileSuccess;
zombieCount = 0;
fstream dataFile;
dataFile.open("Zombies.dat", ios::in);
if(dataFile.fail())
fileSuccess = false;
else
fileSuccess = true;
if(dataFile)
while(!dataFile.eof())
{
/*getline(dataFile, maxCount);
getline(dataFile, zombies[zombieCount].health,'\n');
getline(dataFile, zombies[zombieCount].distance,'\n');
*/
dataFile >> maxCount;
dataFile >> zombies[zombieCount].health;
dataFile >> zombies[zombieCount].distance;
++zombieCount;
}
dataFile.close();
if(zombieCount > maxCount)
{
fileSuccess = false;
}
return fileSuccess;
}
|
Hear is my makefile to compile the program on linux
ZombieApocalypse: InternalTools.cpp ExternalTools.cpp Main.cpp
g++ -static InternalTools.cpp ExternalTools.cpp Main.cpp -o ZombieApocalypse
Hear is the file zombie.dat
2
100
10
150
13
Line 1- Holds the maximum amount of zombies
Line 2- Stores health of zombie
Line 3 - Stores the distance to the zombie and player
Line 4&5 - Repeat of line 2&3
PLEASE HELP ME GET THIS PROGRAM WORKING