Hello all,
When compiling the following files, the error that I get is:
In function `operator<<(std::basic_ostream<char, std::char_traits<char> >&,
ArgSequence const&)': multiple definition first defined here error.
The files are as follows:
ansi.h header file with declarations and defintions of inline functions for
ansi escape sequences such as background colors and cursor movements.
homescreen.h definition of class Homescreen
homescreen.cpp definitions of class Homescreen functions
scoreboard.h definition of class Scoreboard
scoreboard.cpp definitions of class Scoreboard functions
main.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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
//begin file: homescreen.h
#ifndef HOMESCREEN_H
#define HOMESCREEN_H
class Homescreen{
class functions...
};
#endif
//end file homescreen.h
//begin file: homescreen.cpp
#include <iostream>
#include "homescreen.h"
#include "ansi.h"
using namespace std;
//definitions of class Homescreen functions...
//end file: homescreen.cpp
//begin file: scoreboard.h
#ifndef SCOREBOARD_H
#define SCOREBOARD_H
class Scoreboard{
class functions...
};
//end file: scoreboard.h
//begin file: scoreboard.cpp
#include <iostream>
#include "scoreboard.h"
#include "ansi.h"
using namespace std;
definitions of class scoreboard functions...
//end file: scoreboard.cpp
//begin file: main.cpp
#include <iostream>
#include "homescreen.h"
#include "scoreboard.h"
#include "ansi.h"
int main()
{
//plays the game to be built
return 0;
}
//end file: main.cpp
//The previous files are compiled using a makefile. The makefile is as follows:
all: game
homescreen.o: homescreen.cpp homescreen.h
g++ -c homescreen.cpp
scoreboard.o: scoreboard.cpp scoreboard.h
g++ -c scoreboard.cpp
main.o: main.cpp
g++ -c main.cpp
game: main.o homescreen.o scoreboard.o
g++ -o game main.o homescreen.o scoreboard.o
clean:
rm -f *.o game
|
After trying many differet approaches to fix the compilation error and reading many forums, to no avail, has anything worked. Yes, this is homework question for a data structures class, however, I do not want any code, just possibly any explanation as to where the error is originating from. Thank you for any and all help.