Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

NeeWom

OpenGL Linker Errors with 1st openGL proggy..

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m learnig OpenGL and I''m working on a project... this is my code. /************* My open Gl Window **************/ #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <windowsx.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glaux.h> // Globals float angle = 0.0f; HDC g_HDC; void SetupPixelFormat(HDC hDC) { int nPixelFormat; static PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; nPixelFormat = ChoosePixelFormat(hDC, &pfd); SetPixelFormat(hDC, nPixelFormat, &pfd); } LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { static HGLRC hRC; static HDC hDC; char string[] = "This is My Gl Window"; int width, height; switch(msg) { case WM_CREATE: hDC = GetDC(hwnd); g_HDC = hDC; SetupPixelFormat(hDC); hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); return 0; break; case WM_CLOSE: wglMakeCurrent(hDC, NULL); wglDeleteContext(hRC); PostQuitMessage(0); return 0; break; case WM_SIZE: height = HIWORD(lParam); width = LOWORD(lParam); if (height==0) height = 1; glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, 1.0f, 1000.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); return 0; break; default: break; } return (DefWindowProc(hwnd, msg, wParam, lParam)); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { WNDCLASSEX Nee; HWND hwnd; MSG masg; bool done; Nee.cbSize = sizeof(WNDCLASSEX); Nee.style = CS_HREDRAW | CS_VREDRAW; Nee.lpfnWndProc = WndProc; Nee.hIcon = LoadIcon(NULL, IDI_APPLICATION); Nee.hCursor = LoadCursor(NULL, IDC_ARROW); Nee.cbClsExtra = 0; Nee.cbWndExtra = 0; Nee.hInstance = hInstance; Nee.hbrBackground = NULL; Nee.lpszMenuName = NULL; Nee.lpszClassName = "NeeWom"; Nee.hIconSm = LoadIcon(NULL, IDI_WINLOGO); if (!RegisterClassEx(&Nee)) return 0; hwnd = CreateWindowEx(NULL, "NeeWom", "TItle Bar", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 100, 100, 800, 600, NULL, NULL, hInstance, NULL); if (!hwnd) return 0; ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); done = false; while(!done) { PeekMessage(&masg, hwnd, NULL, NULL, PM_REMOVE); if (masg.message == WM_QUIT) { done = true; } else { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); angle = angle + 0.1f; if(angle >= 360.0f) angle = 0.0f; glTranslatef(0.0f, 0.0f, 0.0f); glRotatef(angle, 0.0f, 0.0f, 1.0f); glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_TRIANGLES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(1.0f, 0.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.0f); glEnd(); SwapBuffers(g_HDC); TranslateMessage(&masg); DispatchMessage(&masg); } } return masg.wParam; } these are the errors I''m getting Linking... Empty Window.obj : error LNK2001: unresolved external symbol _gluPerspective@32 Empty Window.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0 Empty Window.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4 Empty Window.obj : error LNK2001: unresolved external symbol __imp__glViewport@16 Empty Window.obj : error LNK2001: unresolved external symbol __imp__wglDeleteContext@4 Empty Window.obj : error LNK2001: unresolved external symbol __imp__wglMakeCurrent@8 Empty Window.obj : error LNK2001: unresolved external symbol __imp__wglCreateContext@4 Empty Window.obj : error LNK2001: unresolved external symbol __imp__glEnd@0 Empty Window.obj : error LNK2001: unresolved external symbol __imp__glVertex3f@12 Empty Window.obj : error LNK2001: unresolved external symbol __imp__glBegin@4 Empty Window.obj : error LNK2001: unresolved external symbol __imp__glColor3f@12 Empty Window.obj : error LNK2001: unresolved external symbol __imp__glRotatef@16 Empty Window.obj : error LNK2001: unresolved external symbol __imp__glTranslatef@12 Empty Window.obj : error LNK2001: unresolved external symbol __imp__glClear@4 Debug/Neewom GL.exe : fatal error LNK1120: 14 unresolved externals why am I getting these errors?

Share this post


Link to post
Share on other sites
Advertisement
Link opengl32.lib to your program.

Go to Project-Settings-Link tab and add it to the lib list in MS Visual C++ (standard).

Share this post


Link to post
Share on other sites
linker error != compiler error i.e. often has nothing to do with your code. you''re just not linking to the openGL libraries: opengl32.lib & glu32.lib. go configure you''re linker settings properly (check to make sure those libraries are being linked).

the short of the deal is that the gl headers give your compiler the info it needs to compile the programs by supplying it with references to the appropriate function headers. but there''s no code to execute those fctns till the linker is run. the gl libraries contain the compiled versions of the functions that the headers point out.

-me

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!