PDA

View Full Version : why Win16??



sean717
03-18-2003, 11:27 AM
I'm tring to compile my first opengl program
using VC++6 in WINXP,I created a project in VC++ and added all the libs for opengl to that project,then I wrote a really simple program:

#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>

int main(int argc, char** argv)
{
auxInitDisplayMode (AUX_SINGLE | AUX_RGBA);
auxInitPosition (0, 0, 500, 500);
auxInitWindow (argv[0]);

}


then I got following error msg:

--------------------Configuration: tryopengl - Win32 Debug--------------------
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/tryopengl.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

tryopengl.exe - 2 error(s), 0 warning(s)


can anybody explain why this happens?Thanks

nexusone
03-18-2003, 11:32 AM
Look's like you maybe have linked to the old 16 bit library's: opengl.lib, glu.lib .

Link 32 bit library's: opengl32.lib, glu32.lib

mikael_aronsson
03-18-2003, 12:18 PM
No, no no no !!!!!!

You have linked your application as a windows application, this does require a WinMain() function and that one is missing, possibly you would like to set your linker options to create a console application, then your main() function will be called.

You can also set it with the entry point option in the linker settings.

The reason for the @16 is the calling convention, WinMain has 4 arguments, using 4 bytes on the stack each 4*4=16, that's why you have a trailing @16 in the name.

Mikael

Bob
03-18-2003, 12:20 PM
No, this is just the daily Win32 Application vs Console Application problem. Make sure you create the corrext type of project. Console application requires a main function, and a Win32 Application requires a WinMain function.

And that 16 means, if I remember correct, that the linker wants a function that takes 16 bytes of parameters.

Bob
03-18-2003, 12:22 PM
Oh well, 2 minutes too late... At least I was correct that it was 16 bytes of parameters http://www.opengl.org/discussion_boards/ubb/wink.gif