gcc multiple definitions problem

Started by
10 comments, last by cignox1 18 years ago
Ok, as usual, the multiple definitions error appears when I don't expect it... Following the tutorials on the net, in order to use VBO with openGL I need to write the following functions definitions:

PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL;
PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL;
PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL;
PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = NULL;

Gcc doesn't like them, and complaints that all the three functions were already been defined in locale_facets.tcc.
Quote: .objs\util.o: In function `ZSt17__verify_groupingPKcjRKSs': C:/Programmi/CodeBlocks/bin/../lib/gcc/mingw32/3.4.4/../../../../include/c++/3.4.4/bits/locale_facets.tcc:2497: multiple definition of `glBindBufferARB' .objs\main.o:C:/Programmi/CodeBlocks/bin/../lib/gcc/mingw32/3.4.4/../../../../include/c++/3.4.4/bits/locale_facets.tcc:2497: first defined here
I gave a look to this file, but wasn't able to find that string. What's wrong? Thank you.
Advertisement
Interesting, locale_facets.tcc has nothing to do with OpenGL!

The source here is:
/*2494*/  bool/*2495*/  __verify_grouping(const char* __grouping, size_t __grouping_size,/*2496*/		    const string& __grouping_tmp)/*2497*/  {/*2498*/    const size_t __n = __grouping_tmp.size() - 1;/*2499*/    const size_t __min = std::min(__n, __grouping_size - 1);/*2500*/    size_t __i = __n;/*2501*/    bool __test = true;/*2502*/    /*2503*/    // Parsed number groupings have to match the/*2504*/    // numpunct::grouping string exactly, starting at the


I have no idea how that might happen other than some sort of macro substitution going on somewhere. Maybe it's something to do with where you declared these things...

The internet seems to have very little to say about this problem.
Wierd.

Maybe GCC was hashing variable names internally for the sake of lookup and two things ended up with the same value. That's my only guess, and it's a long shot.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
Yes, that file has nothing to do with openGL. One more strange thing is that if I comment out those definitions, the compiler says that the functions have not been declared :-(
I love C++
I hate C++
I love C++
How about if you change their names? It should rule out some causes..
I tried, but the result is the same: if I remove ARB from the names, it keeps to say that it was already defined.
I prefer not to use external libraries to load the extensions, because this is the first time I use them and would like to use the old way.
And this error makes me *?!=!!!
Is that in a source file or a header file?
Is PFNGLBINDBUFFERARBPROC defined somewhere?
Quote:Original post by Nitage
Is that in a source file or a header file?


If I put them in a source file, then other sources may be unable to see them. In fact, if I put them in a cpp, the compiler tells me that when I try to use them they are undefined (I suppose that this is bound to the order of compilation?)

Quote:
Is PFNGLBINDBUFFERARBPROC defined somewhere?

Should be defined in the file glext.h, than I include from my own headers that need it.
They should be placed in a CPP file, and in a header file you should declare them as extern.

cpp:

PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL;
PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL;
PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL;
PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = NULL;

h:
extern PFNGLBINDBUFFERARBPROC glBindBufferARB;
extern PFNGLGENBUFFERSARBPROC glGenBuffersARB;
extern PFNGLBUFFERDATAARBPROC glBufferDataARB;
extern PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB;

This topic is closed to new replies.

Advertisement