Qt World Summit: Submit your Presentation

[SOLVED] Undefined reference to '_imp___...' when compiling DLL

  • Hey all I'm been searching awhile and I can't find a solution so... I'm trying to build this dynamic library and it keeps outputting this type of errors:

    error: undefined reference to Enum::toString() const' error: undefined reference to_imp___ZN4EnumC2Ei'
    error: undefined reference to `_imp___ZN4EnumD2Ev'

    and in my *.pro file I have DEFINES += CUSTOMER_DLL, so I'm kinda guessing the problem can be determined from these 2 files:

    #ifndef CUST_TYPE_H
    #define CUST_TYPE_H

    #include <enum.h>
    #include "cexport.h"

    class CUSTOMER_EXPORT CustomerType : public Enum {
    CustomerType(int value=0): Enum(value) {}
    CustomerType(QString ctyp);
    const NameMap& nameMap() const;



    #include <QtGlobal>

    /** Macro definition for exporting symbols to a DLL on Windows */

    #ifndef Q_OS_WIN
    #elif defined(CUSTOMER_DLL)

    #endif // #ifndef CUSTOMER_EXPORT

    This is part of the source code from 'An Introduction to Design Patterns in C++ with Qt' in the libs folder. Let me know if I'm missing out anything.

    Windows 7 32bit, Qt 4 and 5

  • You need to link to the library that contains the compiled Enum class that you are trying to subclass. Your PRO file probably need a LIBS entry to suit. I don't have that source so I cannot be certain of precisely what's required.

  • You're right... so I removed an include to a *.pri file and add the library

    win32: LIBS += -L$$PWD/../../build-libs-Qt_5_0_2-Debug/dataobjects/debug/ -ldataobjects

    I know it sounds vague and all but thanks!

Log in to reply