
please wait
|
|
|
|
The message text is clear enough. Variable h1 is defined several times. It seems that you placed the definition in a header file and included that header in several modules. |
|
|
|
|
|
|
|
|
extern GLHandler * h1;
GLHandler * h1 = new GLHandler();
They will be defined once for each source file they are included in. In total that becomes many times. A solution is to put an extern declaration in the header extern GLHandler * h1; and but the definition in a source file. GLHandler * h1 = new GLHandler(); |
extern GLHandler * h1;
|
|
You are wrong saying that variable h1 is defined only once in header GLHandler.h. The compiler deals with translation units. You have at least two translation units: one that is formed from Timer.cpp and its including headers and other that is formed from GLHandler.cpp and its including headers. As the both translation units have source lines from GLHandler.h then the both define variable h1 that has external linkage. So the linker sees that there are two definitions of external variable h1 one of which is in the first translation unit and other in the second translation unit. And it does not know which definition to include into the result executable module. You should place in the header only the declaration of h1 if it need to be visible in several translation ubits that will include the header. for example GLHandler.h extern GLHandler * h1; and define the variable only in one translation unit, for example, in GLHandler.cpp 12345678 #include <GL/glut.h> #include "GLHandler.h" using namespace std; GLHandler * h1 = new GLHandler(); // and so on |