views:

37

answers:

2

I'm trying to get the addresses for the VBO addon. In my stdafx.h I have the gl.h, glext.h and wglext.h

If I do: glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB"); glGenBuffersARB(0,0);

in stdafx.cpp, this will compile. but if I try to use glGenBuffersARB(0,0); in any of my other h or cpp files I get:

Error   11  fatal error LNK1169: one or more multiply defined symbols found C:\Users\Josh\Documents\Visual Studio 2008\Projects\Vectorizer Project\Release\Vectorizer Project.exe
Error   10  error LNK2005: _glGenBuffersARB already defined in OGLENGINE.obj    stdafx.obj

what is the proper way of doing this so I can use the vbo extension anywhere in my code?

Thanks

A: 

You have a linking error that looks like you have more than one definition for glGenBuffersARB. As a first debugging step I would change it so that the name of you function pointer is not the same as the name of the function that you are getting the address of.

fp_glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB"); 

It may be that the function is already defined with the name glGenBuffersARB in a library that you are linking to.

You don't show what context you are calling wglGetProcAddress or what scope your variable glGenBuffersARB (or fp_glGenBuffersARB following my rename) has but you must ensure the there is only a single definition for it. You can forward declare it in a header file but you must just have a single definition.

Charles Bailey
+5  A: 

_glGenBuffersARB already defined

You probably declared glGenBuffersARB as a global variable in a header (*.h) file, and forgot to add "extern".

what is the proper way of doing this so I can use the vbo extension anywhere in my code?

Use GLEE or GLEW.

SigTerm
I second SigTerm. Managing extensions yourself is a tedious and error prone process...
miquelramirez