Sign in to follow this  

Little linker probs

This topic is 4355 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there! Today is one of those days when nothing seems to work. For the first time in months I've got some crazy linker errors I can't get rid of (thought those times were through...pretty emberassing). I've created a header file, in which I declare some HLSL extensions:
#ifndef hc_OpenGLExtensions
#define hc_OpenGLExtensions


// Extensions needed for GLSL
PFNGLCREATEPROGRAMOBJECTARBPROC		glCreateProgramObjectARB;
PFNGLDELETEOBJECTARBPROC			glDeleteObjectARB;
PFNGLUSEPROGRAMOBJECTARBPROC			glUseProgramObjectARB;
PFNGLCREATESHADEROBJECTARBPROC		glCreateShaderObjectARB;
PFNGLSHADERSOURCEARBPROC			glShaderSourceARB;
PFNGLCOMPILESHADERARBPROC			glCompileShaderARB;

#endif

This file gets included by all other files in the project. This leads to this list of errors: CEngineCore.obj : error LNK2005: "void (__stdcall* glUseProgramObjectARB)(unsigned int)" (?glUseProgramObjectARB@@3P6GXI@ZA) already defined in CTimer.obj CEngineCore.obj : error LNK2005: "int (__stdcall* glGetAttribLocationARB)(unsigned int,char const *)" (?glGetAttribLocationARB@@3P6GHIPBD@ZA) already defined in CTimer.obj CEngineCore.obj : error LNK2005: "unsigned int (__stdcall* glCreateProgramObjectARB)(void)" (?glCreateProgramObjectARB@@3P6GIXZA) already defined in CTimer.obj CEngineCore.obj : error LNK2005: "void (__stdcall* glActiveTextureARB)(unsigned int)" (?glActiveTextureARB@@3P6GXI@ZA) already defined in CTimer.obj CEngineCore.obj : error LNK2005: "void (__stdcall* glDeleteObjectARB)(unsigned int)" (?glDeleteObjectARB@@3P6GXI@ZA) already defined in CTimer.obj CEngineCore.obj : error LNK2005: "void (__stdcall* glGetInfoLogARB)(unsigned int,int,int *,char *)" (?glGetInfoLogARB@@3P6GXIHPAHPAD@ZA) already defined in CTimer.obj CEngineCore.obj : error LNK2005: "void (__stdcall* glVertexAttribPointerARB)(unsigned int,int,unsigned int,unsigned char,int,void const *)" (?glVertexAttribPointerARB@@3P6GXIHIEHPBX@ZA) already defined in CTimer.obj CEngineCore.obj : error LNK2005: "void (__stdcall* glAttachObjectARB)(unsigned int,unsigned int)" (?glAttachObjectARB@@3P6GXII@ZA) already defined in CTimer.obj CEngineCore.obj : error LNK2005: "void (__stdcall* glEnableVertexAttribArrayARB)(unsigned int)" (?glEnableVertexAttribArrayARB@@3P6GXI@ZA) already defined in CTimer.obj ... ..and so on. There's over 500 of them!!! I'm pretty sure it's a stupid little mistake but I can't figure it out right now :-( Can anyone give me clue? Thank's a lot guys!

Share this post


Link to post
Share on other sites
Like all global variables, extension pointers stored in header files should be declared extern, and then you need to define them in one source file.

Share this post


Link to post
Share on other sites

This topic is 4355 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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