PDA

View Full Version : linking error with _WinMain@16



10-02-2002, 04:45 PM
I am building a simple progam using some glut commands. The program runs and compiles at school, and I can get it to compile on my home computer, but when i go to build it using vs c++ i get and unresolved external _WinMain@16.
Here's the code. I did download glut.h, glut32.lib, glut.lib, and the .dlls. I'd appreciate your help.
Thanks
springec@cwu.edu
#include<windows.h>
#include<gl/GL.h>
#include<gl/GLAUX.h>
#include<gl/GLU.h>
#include<gl/glut.h>
#include<basetsd.h>

void myInit(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glColor3f(0.0f, 0.0f, 0.0f);
glPointSize(4.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 640.0, 0.0, 480.0);
}

void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
glVertex2i(100, 50);
glVertex2i(100, 130);
glVertex2i(150, 13);
glEnd();
glFlush();
}

void main(int argc, char** argv)
{ glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE
| GLUT_RGB);
glutInitWindowSize(640, 480);
glutInitWindowPosition(100, 150);
glutCreateWindow("my first atempt");
glutDisplayFunc(myDisplay);
myInit();
glutMainLoop();
}

Bob
10-02-2002, 10:44 PM
Search the forum for unresolved external for more information. Basiclly it means you have not created the correct type of project.

tinak
10-02-2002, 10:48 PM
That message appears usually if you are creating a windows application with GLUT. Because a windows application usually starts with a WinMain routine the compiler is trying to locate it. To use GLUT the ideal application type is console which starts with a main routine.

However, this can be worked around in MSVC++ by adding the following to the project:

Either change the project options in the build->settings->link tabs so that it contains /subsystem:console instead of /subsystem:windows..... or ....... add #pragma comment( linker, "/entry:\"mainCRTStartup\"" )
to the top of the source file . I use the second option most of the time when I choose to have a windows based GLUT program but I tested the first option and that worked just as fine...

Hope that helps

Tina