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. Dll link Error with static function
Forum Updated to NodeBB v4.3 + New Features

Dll link Error with static function

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 1.8k Views 3 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.
  • DongD Offline
    DongD Offline
    Dong
    wrote on last edited by
    #1

    Hi everyone !

    I got this Compiler Error when Build a Shared Library (which Linked to an other Shared Library)
    This is my situation

    //CommonFunctions.h
    #include "utilities_global.h"
    
    class UTILITIESSHARED_EXPORT CommonFunctions
    {
        static QString GetEnumDescription(QString className, int enumValue);
    }
    

    And then I'm use it in Bussiness class like this

    //SomeBusiness.cpp
    QVariant valueDisplay = cf.GetEnumDescription(propColMapping.EnumType, provalue.value<int>());
    

    Business Project already linked to Utilities Dll

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../build/Framework/Utilities/release/ -lUtilities
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build/Framework/Utilities/debug/ -lUtilities
    else:unix: LIBS += -L$$PWD/../../build/Framework/Utilities/ -lUtilities
    
    INCLUDEPATH += $$PWD/../Utilities
    DEPENDPATH += $$PWD/../Utilities
    

    Did I missing something? Or this is a limitation?
    Anyway to make it work ?!

    Thanks you very much !!!

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      If you could post the compiler error it might be more helpful but my first guess is that the method is private, you need to add public: in front of it

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Also, just as a note
        if its a static method, why do you call it via an instance?
        I would expect something like

        Variant valueDisplay = CommonFunctions::GetEnumDescription(xxx);

        http://www.learncpp.com/cpp-tutorial/812-static-member-functions/

        1 Reply Last reply
        3
        • DongD Offline
          DongD Offline
          Dong
          wrote on last edited by
          #4

          My mistake...!!!

          I'm trying to convert old Static Library to Shared Library.
          But I forgot to remove

          //Utilities.pro
          CONFIG += staticlib
          

          @VRonin : Issues List show something like this:

          //error: undefined reference to `_imp___ZN15CommonFunctions18GetEnumDescriptionE7QStringi'
          

          @mrjj : I'm try to call it with instance but it doesn't work too.

          kshegunovK 1 Reply Last reply
          0
          • DongD Dong

            My mistake...!!!

            I'm trying to convert old Static Library to Shared Library.
            But I forgot to remove

            //Utilities.pro
            CONFIG += staticlib
            

            @VRonin : Issues List show something like this:

            //error: undefined reference to `_imp___ZN15CommonFunctions18GetEnumDescriptionE7QStringi'
            

            @mrjj : I'm try to call it with instance but it doesn't work too.

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @Dong said in Dll link Error with static function:

            Issues List show something like this:
            //error: undefined reference to `_imp___ZN15CommonFunctions18GetEnumDescriptionE7QStringi'

            You have a linker error. Make sure you have exported the function (it must be in the public section of the exported class) and that you have properly set the linker's additional libraries (the LIBS variable).

            Kind regards.

            Read and abide by the Qt Code of Conduct

            DongD 1 Reply Last reply
            2
            • kshegunovK kshegunov

              @Dong said in Dll link Error with static function:

              Issues List show something like this:
              //error: undefined reference to `_imp___ZN15CommonFunctions18GetEnumDescriptionE7QStringi'

              You have a linker error. Make sure you have exported the function (it must be in the public section of the exported class) and that you have properly set the linker's additional libraries (the LIBS variable).

              Kind regards.

              DongD Offline
              DongD Offline
              Dong
              wrote on last edited by Dong
              #6

              @kshegunov Thanks you !
              I'm already found the problem which mentioned in my reply above !

              Many 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