Skip to main content
gamedev.net
🔒 Locked

redeclaration of C++ built-in type

Started by Wavesonics 33 replies 37.8k views
Original Post
Wavesonics
Wavesonics
I'm trying to get OpenGL set up with Dev C++ and it's not going so well... I get this error when I try to compile. 50 C:\Dev-Cpp\include\GL\glut.h redeclaration of C++ built-in type `wchar_t' From when I can gather I'm not the only 1 w\ this problem. This problem is the standard is there can not be two identical type defs. The reason this isn't a show stopper is VC++ isn't standards compliant, it just lets anything fly. So all VC++ users are fine, don't ever know this conflict exists. But the rest of us using standards compliant compilers such as Dev C++'s MinGW or what ever they call it... any way no 1 i have found so far has figured a solution, PLZ HELP!
Wavesonics
Wavesonics
UPDATE:
I commented out line 50 and that error goes away.

But then I get 10 million link errors :(
example:

[Linker error] undefined reference to `__glutInitWithExit'

wtf why does the opengl god hate me so...
Fruny
Fruny
Are you sure your glut.h header matches the library file you are using?
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Fruny
Fruny
Quote:
Original post by Wavesonics
Is the commenting out line 50 a good idea or should i find a different work around?


Sure, hack it away - if the header doesn't work, it does you no good. I did the same thing when I started using VS.NET, which had changed the declaration for exit() and abort() - adding a noreturn attribute.

Your best bet in any case would be to recompile GLUT from source, that way, you'd be sure everything is clean. May I suggest FreeGLUT? Unlike the original GLUT, it is still being maintained, and the license terms are better (you can redistribute a modified copy). It also comes with a Dev-C++ package, apparently.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Wavesonics
Wavesonics
awesome thx man. Ok got an interesting development. Some 1 in another forum linked me 2 some OpenGL projects and I compiled 1 of them and ya know what?

NO LINK ERRORS!!!! WTF?! they use the exact same include I do for glut.h!

Heres the difference. It's a "Project" so it has it's own link parameters. But I copied them strait into my global link parameters so everything compiled should be the same now. But my sample code is still busted. How could 1 give me link errors and 1 not?!

Heres the exact linking I use:
-L"C:\Dev-Cpp\lib" -lopengl32 -lglu32 -lglut32
Fruny
Fruny
*shrug* Your compiler hates you?

No, really, I don't know. Check that all the settings match, including library path options (-L) and so on and so forth...

edit - hmmm, ok...
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Wavesonics
Wavesonics
ya it really really does hate me :(... it's gotta b something w\ the code or something i have no idea. just doesnt make sense this 1 project would compile while the other would give linking errors...
Wavesonics
Wavesonics
I just compile a file with:

#include

thats it and i still get 3 errors... Heres the full compile log:

Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Dev-Cpp\my code\openGL\my code\test\stupid.cpp" -o "C:\Dev-Cpp\my code\openGL\my code\test\stupid.exe" -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -I"C:\Dev-Cpp\include\GL" -L"C:\Dev-Cpp\lib" -lopengl32 -lglu32 -lglut32
C:\DOCUME~1\ADAMBR~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x15):stupid.cpp: undefined reference to __glutInitWithExit'
C:\DOCUME~1\ADAMBR~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x30):stupid.cpp: undefined reference to
__glutCreateWindowWithExit'
C:\DOCUME~1\ADAMBR~1\LOCALS~1\Temp/ccK0baaa.o(.text+0x4c):stupid.cpp: undefined reference to __glutCreateMenuWithExit'
C:\Dev-Cpp\lib/libmingw32.a(main.o)(.text+0x7f):main.c: undefined reference to
WinMain@16'

Execution terminated
Acid-Chris
Acid-Chris
MAN....it's always the same, on every compiler, on every platform,...CHECK YOUR PROJECT AND LINKER SETTINGS!!!

...But if you cannot setup your little program to compile properly what if you're getting _real_ compile errors? Post them immediately to some boards?? Fine! *being sarcastic* :(

I'm sure we hear from you again if you add another 3rd party library...*gg*

best regards
- christoph -
Fruny
Fruny
Look in the header file see if there are references to glutInitWithExit, glutCreateWindowWithExit and glutCreateWindowWithExit, like, for example, taking their address (function pointers?).

You can also get your preprocessor to dump the list of macros it has implicitely defined (IIRC, cpp -dM) -- see if things are different in the project that worked. Or compare the preprocessed output, see if the naughty bits are taken out somehow, or actually made correct.

Does MinGW-g++ need to link to other libraries to provide WinMain, or is that the usual entry point?

Also, see if using FreeGLUT makes things better.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Zyme
Zyme
i am no expert in this but i have had the same sort of problems while trying to compile managed types with none managed types, i would suggest this if you do not want to use a 3rd party glut.

#undef wchart_t#include <glut.h>


it may solve your problem but may also create more problems i am unsure of this.

(edit: ignore me if u feel the need as i am probably to inexperienced in this to be of any help)
Zyme the fruit of um, er k what ever :D
Fruny
Fruny
wchar_t is not a macro, it's a built-in type, just like char, short, int, long, float and double are.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Wavesonics
Wavesonics
Ok that project I thought was working is only using gl and glu...

But Dev C++ generates templates 1 of which is a basic open GL window which WAS compiling eariler 2 nite and now does not. So I just need to reset all my fucking headers and libs. This FreeGlut seems to b native to Linux, having a lil trouble finding the win32 binaries but ill keep looking.
Fruny
Fruny
Check your library path.
exit() is declared in /
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Wavesonics
Wavesonics
awesome ok fixxed the exit problem. Now no matter which lib i use it says it cant b found...

Both the libfreeglut.a and libglut32.a
opengl really does hate :(....

so close too so close...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.