PDA

View Full Version : More Environmental Problems



AsylumX
05-11-2002, 06:21 PM
Ok, I'm still new to OpenGL and I still can't get my environment set up to compile it properly. I upgraded to vc++ 6.0, got the proper libs and everything from sgi... I still get linker errors that I don't understand. Check this out:

Compiling...
rectangle.C
Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/rectangle.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

This looks familiar, but I'm used to working in a unix environment at the college and I'm not sure how to solve this. Any ideas would be appreciated! I guess I just don't understand why _WinMain would be an unrecognized symbol, since it is not something that I have directly called.

ps if you are on ICQ I can be reached at 3111909 if you'd be willing to help me!

[This message has been edited by AsylumX (edited 05-11-2002).]

mproso
05-12-2002, 12:47 PM
When making new project you must set it to Win32 Application and every
windows program must start with WinMain function not main.
Visual C++ comes with headers for OpenGL.
Look for it in MSDN.
Hope this helps.

AsylumX
05-12-2002, 02:28 PM
Thanks but I still don't quite understand. So instead of int main(...) I should have int WinMain(...)? If I try that, I still get the same error and some warnings, too.

I have the project set up as a win32 application, so that's taken care of.

hrm...

Am I the only person in the programming world who can't get OpenGL to compile right? This is very discouraging!

Just a side note, not sure if this matters, but I'm attempting to use glut in my first program here. I have the headers installed in what appear to be the proper directories as well as the libs and dlls, etc.

[This message has been edited by AsylumX (edited 05-12-2002).]

chowe6685
05-12-2002, 04:18 PM
your code expects a console app not a win32 app.
you need to replace void main() with
int WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
not just WinMain()

hope that helps

AsylumX
05-12-2002, 07:31 PM
Ah, that helps a ton!

But now how do I get argc and argv? Here is the WinMain func.

__stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow("Hello");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

Perhaps I need to tokenize lpCmdLine? Or is there a different way to call glutInit(...)?

You guys are very helpful, though, and I appreciate the time you put in to these boards to get newbies like me going!

-AsylumX

(init() and display() are defined elsewhere in my code.)

[This message has been edited by AsylumX (edited 05-12-2002).]

mproso
05-12-2002, 10:52 PM
Well if you are using glut then you can compile an link your program as Win32 Console Application and you can use main function. Just make sure you are linking with
right dlls (glut32.lib, opengl32.lib, glu32.lib) and include glut.h( it includes
gl.h and glu.h files).
There is no need for Win32 API when you use glut.
There are lots of simple examples on net that should compile without problems.
Hope this helps.

Bob
05-12-2002, 11:49 PM
My advice is: create a whole new project, and create a console app this time.

There are two types of projects you can create; Win32 Console App, and Win32 App. Win32 App wants a WinMain(), and a Console App want a main(). Look at your code, and create the right project depending on which of these functions are present.

AsylumX
05-13-2002, 01:48 AM
Sweet! I finally got it to compile and run! You folks are awesome!

I'm sure I'll be back a lot in the next couple of months, I'm taking a CG course and in the spring semester... this is going to be a challenge.

Thanks again for all the help!

-AsylumX