Sign in to follow this  
omagaalpha

error can't figure out to solve

Recommended Posts

graphic api: Opengl(though not need really don't think) compiler: Dev-c++ Error aplication if can red it is multple difenintion
Quote:
introduction.o: In function `ZN12introduction18GLRender_to_screenEv': C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/introduction.cpp:19: multiple definition of `active' main.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/main.cpp:40: first defined here introduction.o: In function `ZN12introduction18GLRender_to_screenEv': C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/introduction.cpp:19: multiple definition of `fullscreen' main.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/main.cpp:40: first defined here introduction.o: In function `ZN12introduction18GLRender_to_screenEv': C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/introduction.cpp:19: multiple definition of `g_currenscreen_info' main.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/main.cpp:40: first defined here introduction.o: In function `ZN12introduction18GLRender_to_screenEv': C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/introduction.cpp:20: multiple definition of `texture' main.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/main.cpp:40: first defined here collect2: ld returned 1 exit status make.exe: *** [Lesson1.exe] Error 1 Execution terminated
File all of these are in is global_declaration.h
 #ifndef __GLOBAL_DECLARATION_H__
#define __GLOBAL_DECLARATION_H__

//#include <gl\gl.h>												// Header File For The OpenGL32 Library
#include "tga.h"

bool	keys[256];												// Array Used For The Keyboard Routine
bool	active;											// Window Active Flag Set To TRUE By Default
bool	fullscreen;										// Fullscreen Flag Set To Fullscreen Mode By Default

struct screeninfo
{
int g_width;
int g_height;
int g_bpp;
};

screeninfo g_currenscreen_info;

Texture texture[3];												// Storage For 2 Textures ( NEW )

#endif

plan refence to file for global variables

Share this post


Link to post
Share on other sites
In order to use a global variable in a header file you need to declare it as extern. Ex:

extern int i;

Then in one source file you define the global variable. That is you put

int i;

in a single source file at namespace scope (not inside a class or function). For more details see this article.

Share this post


Link to post
Share on other sites
global_declaration.h
#ifndef __GLOBAL_DECLARATION_H__
#define __GLOBAL_DECLARATION_H__

//#include <gl\gl.h> // Header File For The OpenGL32 Library
#include "tga.h"

extern bool keys[256]; // Array Used For The Keyboard Routine
extern bool active; // Window Active Flag Set To TRUE By Default
extern bool fullscreen; // Fullscreen Flag Set To Fullscreen Mode By Default

struct screeninfo
{
int g_width;
int g_height;
int g_bpp;
};

extern screeninfo g_currenscreen_info;

extern Texture texture[3]; // Storage For 2 Textures ( NEW )

#endif





global_declaration.cpp
#include "global_declaration.h"

bool keys[256]; // Array Used For The Keyboard Routine
bool active; // Window Active Flag Set To TRUE By Default
bool fullscreen; // Fullscreen Flag Set To Fullscreen Mode By Default





error report
Quote:
Compiler: Default compiler
Building Makefile: "C:\james\programming\tutorials\project it game time with phases\opengl\lesson01\Makefile.win"
Executing make...
make.exe -f "C:\james\programming\tutorials\project it game time with phases\opengl\lesson01\Makefile.win" all
g++.exe -D__DEBUG__ -c global_declaration.cpp -o global_declaration.o -I"C:/james/programming/openal sdk/dll" -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include" -g3

g++.exe -D__DEBUG__ main.o tga.o common_shapes.o game_stage.o introduction.o manages_game_stage.o global_declaration.o global_include.o Lesson1_private.res -o "Lesson1.exe" -L"C:/james/programming/openal sdk/libs" -L"lib" -mwindows -lopengl32 -lglu32 -lglaux -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -g3

introduction.o: In function `ZN12introductionC2Ev':
C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/introduction.cpp:7: multiple definition of `keys'
common_shapes.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/common_shapes.cpp:7: first defined here
introduction.o: In function `ZN12introduction18GLRender_to_screenEv':
C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/introduction.cpp:19: multiple definition of `active'
common_shapes.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/common_shapes.cpp:26: first defined here
introduction.o: In function `ZN12introduction18GLRender_to_screenEv':
C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/introduction.cpp:19: multiple definition of `fullscreen'
common_shapes.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/common_shapes.cpp:26: first defined here
introduction.o: In function `ZN12introduction18GLRender_to_screenEv':
C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/introduction.cpp:19: multiple definition of `g_currenscreen_info'
common_shapes.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/common_shapes.cpp:26: first defined here
global_declaration.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/global_declaration.cpp:(.bss+0x0): multiple definition of `keys'
common_shapes.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/common_shapes.cpp:7: first defined here
global_declaration.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/global_declaration.cpp:(.bss+0x100): multiple definition of `active'
common_shapes.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/common_shapes.cpp:26: first defined here
global_declaration.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/global_declaration.cpp:(.bss+0x101): multiple definition of `fullscreen'
common_shapes.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/common_shapes.cpp:26: first defined here
main.o: In function `Z14LoadGLTexturesv':
C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/main.cpp:29: undefined reference to `texture'
C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/main.cpp:29: undefined reference to `texture'

C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/main.cpp:29: undefined reference to `texture'
C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/main.cpp:38: undefined reference to `texture'
C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/main.cpp:39: undefined reference to `texture'
main.o:C:/james/programming/tutorials/project it game time with phases/opengl/lesson01/main.cpp:40: more undefined references to `texture' follow
collect2: ld returned 1 exit status

make.exe: *** [Lesson1.exe] Error 1

Execution terminated

Share this post


Link to post
Share on other sites
nvm above post just had do total clean build for it to work.
Oh, last time before try external on to varaible forgoted include varaible in cpp of the file also.

Share this post


Link to post
Share on other sites
Anyway after Mathematix comment I was able to figure out what had to do. My post after his post as soon as I post it realise that had do rebuild all. Only reason did not deleted all that post is against delete post when at all possible.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this