Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Undefined reference to '_imp___...' when compiling DLL
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 8.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bruceoutdoors
    wrote on last edited by
    #1

    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:

    custType.h
    @
    #ifndef CUST_TYPE_H
    #define CUST_TYPE_H

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

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

    };
    #endif
    @

    cexport.h
    @
    #ifndef CUSTOMER_EXPORT

    #include <QtGlobal>

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

    #ifndef Q_OS_WIN
    #define CUSTOMER_EXPORT
    #elif defined(CUSTOMER_DLL)
    #define CUSTOMER_EXPORT Q_DECL_EXPORT
    #else
    #define CUSTOMER_EXPORT Q_DECL_IMPORT
    #endif

    #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

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bruceoutdoors
        wrote on last edited by
        #3

        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!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved