PDA

View Full Version : My openGL program wont link!



newbie
11-13-2000, 11:47 AM
Hi!
I was trying to run a code example from the book i'm trying to learn openGL from, and it won't work (VERY disappointed http://www.opengl.org/discussion_boards/ubb/frown.gif ) I'm using VC++ 6.0.

Please help me, i really want to learn!

CODE (from openGL programming guide third edition):


#include "GL/glut.h"

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.25, 0.25, 0.0);
glEnd();

glFlush();
}


void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}


int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow("hello");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}


ERROR:


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

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

Deiussum
11-13-2000, 11:52 AM
Looks like you started the project as a Win32 Application. Start it as a Win32 console instead.

newbie
11-13-2000, 04:37 PM
Ive tried that already... Nothing works...

ViRuS
11-13-2000, 05:24 PM
my problem is quite similar..i cant figure it out either

Alias-X
11-13-2000, 06:28 PM
Well, I don't use glut so I'm not sure if it matters whether or not your using a win32 or console application but my guess would be win32 is fine. In any case try doing this.

<pre>
1. Go to 'Project'->'Settings'.
2. Locate te 'Link' tab.
3. In the 'Category' combo box choose 'Input'. (It's probably set to 'General' right now.)
4. Now in the edit box for 'Ignore libraries' type this...
LIBCD,LIBC.lib
5. That should take care of the problem I believe, then again I never have used glut so I don't know how its window creation code works.

Good Luck,
Alias-X

jc
11-13-2000, 11:12 PM
are you linking with the windows lib (like winmm.lib) and did you include the "windows.h" file ??

Spitz
11-14-2000, 03:34 AM
add this 3 lines under #include<GL/glut.h>

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "glut32.lib")

newbie
11-14-2000, 03:52 AM
Thanks all! I'll try it!

Deiussum
11-14-2000, 05:11 AM
The problem is that your program is looking for a WinMain() function for the entry point instead of main(). Since you didn't implement that, it can't find it, thus you get a linker error. A win32 Application differs from a Win32 console in that the application sets the entry point as WinMain() and console uses the entry point as main().

If you tried it by starting the project as a Win32 Console, you shouldn't have gotten the same error.

11-14-2000, 02:57 PM
heh, still a little used to VB, are we? http://www.opengl.org/discussion_boards/ubb/biggrin.gif