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

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

  • giovedì 20 ottobre 2005 20:50
     
     
    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

     

Tutte le risposte

  • giovedì 20 ottobre 2005 21:34
    Moderatore
     
     Con risposta

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

  • venerdì 21 ottobre 2005 04:29
     
     
    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 .
  • venerdì 21 ottobre 2005 14:44
    Moderatore
     
     Con risposta

    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.

  • venerdì 21 ottobre 2005 18:21
     
     
    ok, thanks for everything i sure learned alot from you.
  • domenica 6 novembre 2005 15:31
     
     

    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

  • domenica 6 novembre 2005 16:44
    Moderatore
     
     
    Define the main() function.
  • domenica 6 novembre 2005 16:44
     
     Con risposta
    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
    =======================================================
  • mercoledì 19 settembre 2007 22:04
     
     
    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
  • venerdì 21 settembre 2007 13:22
     
     
    I have exactly the same problem.. Anyone solved this yet?
  • lunedì 26 novembre 2007 05:45
     
     

    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.

     

  • domenica 23 marzo 2008 13:59
     
     
    that was very helpful DJ, thanks! it works for my problem Smile
  • mercoledì 21 gennaio 2009 19:31
     
     
     Hello,

    I havnt a clue what is coing on with these three errors.

    I think its somthing to do with the linker. but I have  not dealt much with that yet.

    here is the error:

    1>moc_mavcom.obj : error LNK2019: unresolved external symbol "private: void __thiscall Mavcom::on_pushButton_clicked(void)" (?on_pushButton_clicked@Mavcom@@AAEXXZ) referenced in function "public: virtual int __thiscall Mavcom::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Mavcom@@UAEHW4Call@QMetaObject@@HPAPAX@Z)

    1>moc_about.obj : error LNK2019: unresolved external symbol "private: void __thiscall about::on_textBrowser_textChanged(void)" (?on_textBrowser_textChanged@about@@AAEXXZ) referenced in function "public: virtual int __thiscall about::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@about@@UAEHW4Call@QMetaObject@@HPAPAX@Z)

    1>moc_about.obj : error LNK2019: unresolved external symbol "private: void __thiscall about::on_pushButton_clicked(void)" (?on_pushButton_clicked@about@@AAEXXZ) referenced in function "public: virtual int __thiscall about::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@about@@UAEHW4Call@QMetaObject@@HPAPAX@Z)

    Thanks in advance

  • mercoledì 21 gennaio 2009 23:26
     
     
    Barb3958, in future, create a new thread for a new question, rather than resurrecting a dead thread that nobody cares about anymore.

    Quite simply, you are using three functions in your program:

    on_pushButton_clicked()
    on_textBrowser_textChanged()
    on_pushButton_clicked()

    but they are not implemented anywhere where the linker can find them.
  • giovedì 22 gennaio 2009 15:27
     
     
    O! Ok,

    Sorry I am new to forums. I will not do that again.

    Thank you, that helped alot.
  • venerdì 8 gennaio 2010 03:49
     
     
    well try changing ur subsystem from console to windows from the project solutions /input/systems..
  • venerdì 29 ottobre 2010 07:03
     
     

    Hello!

     

    I have these errors a lot and I find myself to always have to copy the DLLs into the directory of the executables, for instance in the Debug folder of my project. Is there a more elegant way to do so? I have tried to set the VC++ directories so that executables points to where the DLLs are but that doesnt seem to do it. You mentioned "the corresponding DLL's must be on the path"... what does this mean?

  • giovedì 5 aprile 2012 13:20
     
     

    I Think. What Brian meant with directory is that you have to save the .dll in the folder that you save your .exe file in the first place.

    Hope this help you to clarify your doubt about what is meant for directory.

  • lunedì 21 maggio 2012 12:28
     
     

    Yup, it solved my problem. Thanks :)

    For clarity, In front of  Additional Dependencies textbox, you need to provide .lib file e.g. test.lib. Though it has Browse button,

    it doesn't show the list of .lib files required, so you can simply type the lib name required.

    Unresolved External symbol