LNK2019: unresolved external symbol error when i compile my win32 app

I am kinda new at this c++, and i am try to to make a Open GL application that when run will make a cube and rotate it on the screen. When i compile my project I get the about 21 different "LNK2019: unresolved external symbol errors". maybe some one can help me figure this out. If you need the project files I can send it too you. I am using visual studio C++ .net 2003. I also tried this code in visual 2005 and received the same thing.

the error i received are as follows:

Error Messages:

OpenGLCube.obj : error LNK2019: unresolved external symbol _gluPerspective@32 referenced in function "void __cdecl ReSizeGLScene(int,int)" ( ReSizeGLScene@@YAXHH@Z)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function "void __cdecl ReSizeGLScene(int,int)" ( ReSizeGLScene@@YAXHH@Z)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function "void __cdecl ReSizeGLScene(int,int)" ( ReSizeGLScene@@YAXHH@Z)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function "void __cdecl ReSizeGLScene(int,int)" ( ReSizeGLScene@@YAXHH@Z)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glHint@8 referenced in function "int __cdecl InitGL(void)" ( InitGL@@YAHXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glDepthFunc@4 referenced in function "int __cdecl InitGL(void)" ( InitGL@@YAHXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function "int __cdecl InitGL(void)" ( InitGL@@YAHXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glClearDepth@8 referenced in function "int __cdecl InitGL(void)" ( InitGL@@YAHXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function "int __cdecl InitGL(void)" ( InitGL@@YAHXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glShadeModel@4 referenced in function "int __cdecl InitGL(void)" ( InitGL@@YAHXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function "int __cdecl UpdateScene(void)" ( UpdateScene@@YAHXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glVertex3f@12 referenced in function "int __cdecl UpdateScene(void)" ( UpdateScene@@YAHXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glColor3f@12 referenced in function "int __cdecl UpdateScene(void)" ( UpdateScene@@YAHXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function "int __cdecl UpdateScene(void)" ( UpdateScene@@YAHXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glRotatef@16 referenced in function "int __cdecl UpdateScene(void)" ( UpdateScene@@YAHXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glTranslatef@12 referenced in function "int __cdecl UpdateScene(void)" ( UpdateScene@@YAHXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function "int __cdecl UpdateScene(void)" ( UpdateScene@@YAHXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__wglDeleteContext@4 referenced in function "void __cdecl KillGLWindow(void)" ( KillGLWindow@@YAXXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__wglMakeCurrent@8 referenced in function "void __cdecl KillGLWindow(void)" ( KillGLWindow@@YAXXZ)

OpenGLCube.obj : error LNK2019: unresolved external symbol __imp__wglCreateContext@4 referenced in function "int __cdecl InitInstance(struct HINSTANCE__ *,int,int,int)" ( InitInstance@@YAHPAUHINSTANCE__@@HHH@Z)

Debug/OpenGLCube.exe : fatal error LNK1120: 20 unresolved externals

 



Answer this question

LNK2019: unresolved external symbol error when i compile my win32 app

  • UnRusoDeCaracas

    Hi Brian

    I have done all as said in your post. But i dont understand what do u mean when u say the .dll have to be in the same directory as the exe.

    I am trying to setup opengl on my computer. I am using windows Xp and have placed all .dll files in the system32 folder. I have the .lib files in the \Program Files\Microsoft Visual Studio 8\vc\lib. I have the libs added to the linker settings in the visual studio.

    I have done the dumpbin.exe to tally the symbols used in the program and those present in the .lib and .dll files.

    Still the compilation fails with the same error.
    What else needs to be done

    Thanks and Regards

    pk


  • LeRoi

    Saying it at the beginning, I am not an expert.

    I got the same problem every now and then. Normally I could solve it by include the .lib file and/or if the function is not defined in the .cpp, define it in the .cpp file.

    Today the problem I have experienced is a bit more "nasty", took me a few hours to solve it. (Different solution but same error message I think)

    Basically I was using a colleage's .h and .cpp file (copied from one project into another). Within the .h file it included say, "nasty.h", within this "nasty.h", it contains tons of #ifndef, #define ... and export and extern, etc. I included the "nasty.lib" and the problem was still there. I copied the Preprocessor Definitions (used in the project that I copied those files from), and it solved the problem! It's easy to tell, but not when you are exploring the solution.

    So this might be a solution for you:

    In Visual C++ (.Net 2003), click on the menu Project -> (project name) Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions

    and check if the ones defined there are correct.



  • kaizen

    ok, thanks for everything i sure learned alot from you.
  • Kent15243

    I have exactly the same problem.. Anyone solved this yet

  • clxowen

    You need to link against the OpenGL import library (something.lib).  Add the name of this file to your linker settings.


  • BullZhot

    How do i go about linking the library's to the linker settings, i have three OpenGL lib files i put in the project directory. (GLU32.lib, GLUT32.lib, and OpenGL32.lib). How to i add these lib file to the linker setting And are these the right lib files Also would it help if i email you the project files. if so i need your email address, mine is lew26@msn.com .
  • OoeyGUI

    Right click on your project, choose Properties. Then Linker, then Input.  From these three libraries, add the ones that contain the symbols listed at the top.  I would do this empirically: just add them and see if the linker errors go away.

    But you can also determine the contents of the libs by using dumpbin.exe. On the command line, set the path by running either \Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\vcvars32.bat  or  \Program Files\Microsoft Visual Studio 8\vc\vcvarsall.bat

    And then invoke dumpbin.exe:  dumpbin.exe /exports CLU32.lib

    If these import libraries contain your symbols, you're set to go.  Remember that the corresponding DLL's must be on the path or the same directory as the executable when you run it.

    Note that dumpbin.exe can also be used on the DLL's themselves:  dumpbin.exe /exports CLU32.dll

    Brian

    PS If you can, reedit your first post and delete the source code.  It's not relevant to the problem and makes this thread hard to read.  Thanks.


  • Rajkumar Muthukumar

    Define the main() function.
  • ajp

    basically whatis happening is you have to use the exact symbol that is located in your lib file, it could be a spelled wrong, also it is case sensitive.



    for example:


    example.lib ---> contains
    ==================================
    scope()    ---> symbol in lib file
    create()   ---> symbol in lib file
    pick()       ---> symbol in lib file
    ==================================

    whenyou use the symbol contained in the lib file.


    example code:
    ======================================================
    int main()
    {
       if (c > 100)
       create()          // referenced symbol same as what is in your lib file
                            // symbol referenced is case-sensitive
    } // end main
    =======================================================

  • nancy white

    wheni try to compile my app i get this error:


    MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup

    Debug\Employee.exe : fatal error LNK1120: 1 unresolved externals

    please tell me how to fix it


  • LNK2019: unresolved external symbol error when i compile my win32 app