# Visual Studio 2005 and OpenGL

This topic is 4395 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello! When I used Dev-C++ it worked fine, but I never get anything to work in VS 2005 Express. I want to use OpenGL in VS 2005, but I am having problems with setting it up. I have followed a few tutorials but I can't get it to compile, the error I get is a linking error: "fatal error LNK 1120: 1 unresolved external." Just to explain how I did: I went to the project properties page, clicked 'Linker', then I clicked on the 'Input' label and typed in 'opengl32.lib glu32.lib' in the first row. I have made sure that the required DLLs are in the system directory, so that's not the problem. If anyone could help me out here I would be grateful! - Cerasti [Edited by - Heptagonal on November 9, 2007 9:42:46 AM]

##### Share on other sites
What exactly are those link error messages?

##### Share on other sites
I already have the platform SDK, but do you have to configure it with VS 2005?

(edit) When I installed it I followed those instructions.

The error:
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
fatal error LNK1120: 1 unresolved externals

##### Share on other sites
that's an error that one typically gets when trying to build a windows application using the console application template. Did you start a Win32 Project or a Win32 Console Application?

##### Share on other sites
Yes, but I unchecked 'Console application' and checked 'Windows application'.

##### Share on other sites
OK, I replicated your linker error. All I had to do was comment out my WinMain function. Let's see how you declare your WinMain function... post it up. Did you perhaps forget to define it or include that source file that contains it into your project?

##### Share on other sites
Here it is:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){	static HGLRC hRC;	static HDC hDC;	switch(message)	{		case WM_CREATE:			hDC = GetDC(hWnd);			hRC = wglCreateContext(hDC);			wglMakeCurrent(hDC,hRC);			break;		case WM_DESTROY:			wglMakeCurrent(hDC,NULL);			wglDeleteContext(hRC);			PostQuitMessage(0);			break;	}	return 0;}

##### Share on other sites
You might try including <windows.h> before any openGL header files, rather than afterwards. It's a longshot, but I had a similar problem before that was caused by that.

##### Share on other sites
Windows.h is already included in a file called stdafx.h which VS created for me, I don't know why it got there but I suppose it's important.

• 19
• 10
• 19
• 14
• 20