AHHH!!! HELP!! 😕

i downloaded the nehe’s opengl tutorial 1 visual c++ code and it doesnt seem to want to compile. i am sure i linked everything as it asked but when it compiles, it says:

--------------------Configuration: Lesson1 - Win32 Debug--------------------
Compiling…
Lesson1.cpp
Linking…
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Lesson1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

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

HELP!! whats goin on here???

Heheh, you have the exact opposite problem of someone else here. The Nehe tutorials I’ve looked at don’t use Glut, which typically uses a Win32 console application. You’re apparently using the wgl functions and creating the window yourself so you’ll need to start the project as a Win32 Application.

The linker is looking for a main() function as an entry point into your program and not finding it. What you want is for it to use WinMain() as the entry point instead and a Win32 Application project sets it up like that for you.

The NeHe tuts are good, but I can’t remember if tut 1 was complete or not… try one of the later ones, they’re better, like 18 or 19 (Thanks go to the ppl who do the VB translations… I’m not the greatest C/OpenGL programmer!) Perhaps sub main is declared as void and u r returning something or it’s an int and u rn’t returning something, I don’t know Do you have SP4 installed? Maybe it makes the difference. I got SP4 with my copy of Visual Studio 6.

If that were the case he’d be getting compiler errors, not linker errors.

No, the first suggestion is correct. The application is configured as a console app so the linker is looking for main() as the insertion point. Switch it to a plain Win32 app and it’ll work.