View Full Version : extensions and linking errors
08-04-2003, 06:40 PM
Ive been trying to add extensions in my current project and for some reason no matter what i try i keep getting LNK2005 errors. Is there something wrong w/ using glext.h in Microsoft Visual Studio .Net 2003? Everything i try (writing my own header/using glext) causes this error. Is there something else im supposed to do?
08-05-2003, 05:20 AM
You don't give the error description, or any code so I can only guess. (Sorry, I have only memorized the linker errors up to LNK1000 so far, so I'm not sure exactly which error LNK2005 is.) http://www.opengl.org/discussion_boards/ubb/smile.gif
Are you using function pointers and wglGetProcAddress() to load your extensions? It sounds like you are trying to link to them via an import library, which isn't going to work because the core Opengl32.dll doesn't actually contain the extensions, so opengl32.lib can't import them.
As an example, you should be doing something like so:
LPFNSOMEXTENSIONPROC glSomeExtension = wglGetProcAddress("glSomeExtension");
08-05-2003, 07:32 AM
renderer.obj : error LNK2005: "void (__stdcall* glProgramStringARB)(unsigned int,unsigned int,int,void const *)" (?glProgramStringARB@@3P6GXIIHPBX@ZA) already defined in exts.obj
i get 3 of these for every func i try to init. Currently i have a "global.h" file that has the gl and glext.h includes. then and exts.h that includes the global file. then when including the exts.h into either shaders.h or renderer.h it gives me all these errors.
08-05-2003, 10:14 AM
Sounds like you are probably creating an instance of the function pointers in your headers, then including that header in multiple .c/.cpp files. Instead, what you should do is to declare it extern in the header, then in one and only one source file, create the instance of it.
extern PFNSOMEFUNCTIONPROC glSomeFunction;
// In one and only 1 source file
// Then in some init function that gets called AFTER your context is created...
glSomeFunction = wglGetProcAddress("SomeFunction");
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.