Error ?

This is a discussion on Error ? within the C++ Programming forums, part of the General Programming Boards category; can someone tell me what kind of error this is(using visual cpp): --------------------Configuration: s - Win32 Debug-------------------- Linking... LIBCD.lib(crt0.obj) : ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    27

    Error ?

    can someone tell me what kind of error this is(using visual cpp):

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

  2. #2
    Still A Registered User DISGUISED's Avatar
    Join Date
    Aug 2001
    Posts
    499
    This is a Linker error that has many causes, but usually has something to do with a missing function body after you have placed a prototype for a function in a class and then try to call it. If you are coding the function outside of the class don't forget to use the scope resolution operator to identify the class that it is a member of. This can by caused by other things as well though.

    -Disguised

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >unresolved external symbol _main

    Do you have a main()? Or is this a windows program (WinMain())? If you have a WinMain(), you need to change your options to build a windows program instead of a console program.

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    27
    im using winmain w/opengl. I switched it to win32 but i got this error:

    --------------------Configuration: sw - Win32 Debug--------------------
    Compiling...
    sw.cpp
    c:\program files\microsoft visual studio\myprojects\sw\sw.cpp(163) : fatal error C1010: unexpected end of file while looking for precompiled header directive
    Error executing cl.exe.

    sw.obj - 1 error(s), 0 warning(s)

    what does this mean ?
    Last edited by slx47; 05-09-2002 at 05:58 PM.

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    When you created the application did you chose Win32 Application, or Win32 Console Application?
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >unexpected end of file while looking for precompiled header directive

    No way to know without seeing some code, but it looks like you are missing a line somewhere, or forgot a }.

  7. #7
    Registered User
    Join Date
    May 2002
    Posts
    27
    i select win32 application and my code is:

    Code:
    // Includes
    
    #include <windows.h>
    #include <gl/gl.h>
    #include <gl/glu.h>
    #include <gl/glaux.h>
    
    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 message, WPARAM wParam, LPARAM lParam)
    {
    static HGLRC hRC;
    static HDC hDC;
    char string[] = "Hello World";
    int width, height;
    
    switch (message)
    {
    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, message, wParam, lParam));
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
    {
    WNDCLASSEX windowClass;
    HWND hwnd;
    MSG msg;
    bool done;
    
    windowClass.cbSize = sizeof(WNDCLASSEX);
    windowClass.style = CS_HREDRAW | CS_VREDRAW;
    windowClass.lpfnWndProc = WndProc;
    windowClass.cbClsExtra = 0;
    windowClass.cbWndExtra = 0;
    windowClass.hInstance = hInstance;
    windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
    windowClass.hbrBackground = NULL;
    windowClass.lpszMenuName = NULL;
    windowClass.lpszClassName = "MyClass";
    windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
    
    if (!RegisterClassEx(&windowClass))
    return 0;
    
    hwnd = CreateWindowEx(NULL,"MyClass","The opengl Window Application",WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU | WS_CLIPSIBLINGS, 100,100,400,400,NULL,NULL,hInstance,NULL);
    
    if (!hwnd)
    return 0;
    
    
    ShowWindow(hwnd, SW_SHOW);
    UpdateWindow(hwnd);
    
    done = false;
    
    while (!done)
    {
    PeekMessage(&msg, hwnd,NULL,NULL, PM_REMOVE);
    
    if (msg.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,-5.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(&msg);
    DispatchMessage(&msg);
    }
    }
    return msg.wParam;
    }

  8. #8
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Well, I've got good news and bad news. The good news is your code compiled perfectly on my machine. When I run the .exe, it displays a rotating red triangle. The bad news is this doesn't help you.

    Maybe one of your header files is hosed, like:
    #include <gl/gl.h>
    #include <gl/glu.h>
    #include <gl/glaux.h>

    I'm using the free borland compiler. I guess if you get desparate you can try it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21