Menu

Undefined dll func's from another dll.

2002-11-06
2012-09-26
  • Nobody/Anonymous

    I'm working a dll project that requires me to use some Glut functions, so I have to link to the glut32.dll and import those functions. However, even though I set the linker option "-lglut32" and include the glut.h header, when I reference a function like "glutDisplayFunc" it generates a undefined reference error.

    c:\DevCpp\gui\gui.o(.text+0x1a):gui.c: undefined reference to `glutDisplayFunc@4'
    c:\DevCpp\gui\gui.o(.text+0x2e):gui.c: undefined reference to `glutReshapeFunc@4'
    c:\DevCpp\gui\gui.o(.text+0x42):gui.c: undefined reference to `glutIdleFunc@4'
    Warning: no export definition file provided
    dllwrap will create one, but may not be what you want
    C:\MinGW\Bin\dllwrap: gcc exited with status 1

    This is some of my code

    #ifndef __gui_h__
    #define __gui_h__

    #ifdef __cplusplus
    extern "C" {
    #endif

    #if BUILDING_DLL

    #    define GUIAPI __declspec(dllexport)

    #    define GUIAPIENTRY

    #    define GLUT_DISABLE_ATEXIT_HACK

    #else

    #    define GUIAPI __declspec(dllimport)

    #    define GUIAPIENTRY

    #endif

    #define WIN32_LEAN_AND_MEAN

    #include <windows.h>

    #include <gl/glut.h>

    typedef GLvoid(*PFNGUIDISPLAYCALLBACK)(GLvoid);

    typedef GLvoid(*PFNGUIRESHAPECALLBACK)(GLint iWidth, GLint iHeight);

    typedef GLvoid(*PFNGUIIDLECALLBACK)(GLvoid);

    GUIAPI GLvoid GUIAPIENTRY guiBindInterface(GLuint uiInterface);

    GUIAPI GLvoid GUIAPIENTRY guiGenInterfaces(GLint iNum, GLuint* pInterface);

    GUIAPI GLvoid GUIAPIENTRY guiDeleteInterfaces(GLint iNum, GLuint* pInterface);

    #ifdef __cplusplus
    }
    #endif

    #endif // __gui_h__ //

    #include "gui.h"

    typedef struct {

        PFNGUIDISPLAYCALLBACK m_DisplayFunc;
        PFNGUIRESHAPECALLBACK m_ReshapeFunc;
        PFNGUIIDLECALLBACK    m_IdleFunc;

    } Interface_t;

    Interface_t* g_pInterface;

    GLvoid guiBindInterface(GLuint uiInterface) {

        g_pInterface = (Interface_t*)uiInterface;

        glutDisplayFunc(g_pInterface->m_DisplayFunc);

        glutReshapeFunc(g_pInterface->m_ReshapeFunc);

        glutIdleFunc(g_pInterface->m_IdleFunc);
    }

    GLvoid guiGenInterfaces(GLint iNum, GLuint* pInterface) {

        int i;

        for(i = 0; i < iNum; i++) {

            Interface_t* pBuf = (Interface_t*)malloc(sizeof(Interface_t));

            pBuf->m_DisplayFunc = (void*)0;
            pBuf->m_ReshapeFunc = (void*)0;
            pBuf->m_IdleFunc    = (void*)0;

            pInterface[i] = (GLuint)pBuf;
        }
    }

    GLvoid guiDeleteInterfaces(GLint iNum, GLuint* pInterface) {

        int i;

        for(i = 0; i < iNum; i++) {

            Interface_t* pBuf = (Interface_t*)pInterface[i];

            free(pBuf);
        }
    }

     
    • Nobody/Anonymous

      It sounds like a build error so I doubt the code is the problem - try compiling wihtout building, it should pass ok.
      Make sure the import library is in the same directory as your source code (copy it if you have to). This will be glut32.lib (you might want to download it, try msdn), this is the file you want to link to, not the dll. After doing that you should be able to build.
      You can also try runtime linking (as opposed to loadtime linking). This is also explained in the MSDN website and there are tutorials all over the place.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.