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. QtService (QtSolutions) static linking
Forum Updated to NodeBB v4.3 + New Features

QtService (QtSolutions) static linking

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 2.9k 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.
  • A Offline
    A Offline
    aka000
    wrote on last edited by
    #1

    Hi,
    I am trying to use QtService in my project but I run into problems. I use Visual Studio 2015 on Windows 10 and Qt 5.8.
    I want to link statically so apparently the preferred method is including the code of QtService directly into my VS project.
    The linker says that there are unresolved external symbols. This is apparently due to qtservice.cpp not being compiled even if it is part of the VS project. Has anybody already encountered this?
    Thanks in advance

    1>MyService.obj : error LNK2019: unresolved external symbol "public: __thiscall QtServiceBase::QtServiceBase(int,char * *,class QString const &)" (??0QtServiceBase@@QAE@HPAPADABVQString@@@Z) referenced in function "public: __thiscall MyService::MyService(int,char * *)" (??0MyService@@QAE@HPAPAD@Z)
    1>MyService.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall QtServiceBase::~QtServiceBase(void)" (??1QtServiceBase@@UAE@XZ) referenced in function __unwindfunclet$??0MyService@@QAE@HPAPAD@Z$1
    1>main.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall QtServiceBase::~QtServiceBase(void)" (??1QtServiceBase@@UAE@XZ)
    1>MyService.obj : error LNK2019: unresolved external symbol "public: void __thiscall QtServiceBase::setServiceDescription(class QString const &)" (?setServiceDescription@QtServiceBase@@QAEXABVQString@@@Z) referenced in function "public: __thiscall MyService::MyService(int,char * *)" (??0MyService@@QAE@HPAPAD@Z)
    1>MyService.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QtServiceBase::stop(void)" (?stop@QtServiceBase@@MAEXXZ)
    1>MyService.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QtServiceBase::pause(void)" (?pause@QtServiceBase@@MAEXXZ)
    1>MyService.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QtServiceBase::resume(void)" (?resume@QtServiceBase@@MAEXXZ)
    1>MyService.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QtServiceBase::processCommand(int)" (?processCommand@QtServiceBase@@MAEXH@Z)
    1>main.obj : error LNK2019: unresolved external symbol "public: int __thiscall QtServiceBase::exec(void)" (?exec@QtServiceBase@@QAEHXZ) referenced in function _main
    
    jsulmJ 1 Reply Last reply
    0
    • A aka000

      Hi,
      I am trying to use QtService in my project but I run into problems. I use Visual Studio 2015 on Windows 10 and Qt 5.8.
      I want to link statically so apparently the preferred method is including the code of QtService directly into my VS project.
      The linker says that there are unresolved external symbols. This is apparently due to qtservice.cpp not being compiled even if it is part of the VS project. Has anybody already encountered this?
      Thanks in advance

      1>MyService.obj : error LNK2019: unresolved external symbol "public: __thiscall QtServiceBase::QtServiceBase(int,char * *,class QString const &)" (??0QtServiceBase@@QAE@HPAPADABVQString@@@Z) referenced in function "public: __thiscall MyService::MyService(int,char * *)" (??0MyService@@QAE@HPAPAD@Z)
      1>MyService.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall QtServiceBase::~QtServiceBase(void)" (??1QtServiceBase@@UAE@XZ) referenced in function __unwindfunclet$??0MyService@@QAE@HPAPAD@Z$1
      1>main.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall QtServiceBase::~QtServiceBase(void)" (??1QtServiceBase@@UAE@XZ)
      1>MyService.obj : error LNK2019: unresolved external symbol "public: void __thiscall QtServiceBase::setServiceDescription(class QString const &)" (?setServiceDescription@QtServiceBase@@QAEXABVQString@@@Z) referenced in function "public: __thiscall MyService::MyService(int,char * *)" (??0MyService@@QAE@HPAPAD@Z)
      1>MyService.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QtServiceBase::stop(void)" (?stop@QtServiceBase@@MAEXXZ)
      1>MyService.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QtServiceBase::pause(void)" (?pause@QtServiceBase@@MAEXXZ)
      1>MyService.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QtServiceBase::resume(void)" (?resume@QtServiceBase@@MAEXXZ)
      1>MyService.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QtServiceBase::processCommand(int)" (?processCommand@QtServiceBase@@MAEXH@Z)
      1>main.obj : error LNK2019: unresolved external symbol "public: int __thiscall QtServiceBase::exec(void)" (?exec@QtServiceBase@@QAEHXZ) referenced in function _main
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @aka000 What you are doing is not static linking.
      Can you check where QtServiceBase is located and whether you added that cpp file to your project?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • A Offline
        A Offline
        aka000
        wrote on last edited by
        #3

        You are right, this is not static linking, what I mean is that I don't want to dynamically link to a DLL.
        QtServiceBase is declared in qtservice.h and most of its methods (e.g. constructor and destructor) are defined in qtservice.cpp. These are two of the methods which the linker cannot find. What I cannot understand is why the compiler is not compiling qtservice.cpp, since this is part of the project.
        Right-clicking on qtservice.cpp and choosing "compile" results in the following message:

        1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): warning MSB8018: No outputs specified for item "src\qtservice\src\qtservice.cpp". Its custom build command will be skipped.
        

        But even after searching online I am not totally sure what that means in my case. Any help is appreciated.

        Here is the link to the code of QtService:
        https://github.com/qtproject/qt-solutions/tree/master/qtservice/src

        jsulmJ 1 Reply Last reply
        0
        • A aka000

          You are right, this is not static linking, what I mean is that I don't want to dynamically link to a DLL.
          QtServiceBase is declared in qtservice.h and most of its methods (e.g. constructor and destructor) are defined in qtservice.cpp. These are two of the methods which the linker cannot find. What I cannot understand is why the compiler is not compiling qtservice.cpp, since this is part of the project.
          Right-clicking on qtservice.cpp and choosing "compile" results in the following message:

          1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): warning MSB8018: No outputs specified for item "src\qtservice\src\qtservice.cpp". Its custom build command will be skipped.
          

          But even after searching online I am not totally sure what that means in my case. Any help is appreciated.

          Here is the link to the code of QtService:
          https://github.com/qtproject/qt-solutions/tree/master/qtservice/src

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @aka000 Are you using qmake?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aka000
            wrote on last edited by
            #5

            No I am building my project in Visual Studio 2015 + Qt addin.

            jsulmJ 1 Reply Last reply
            0
            • A aka000

              No I am building my project in Visual Studio 2015 + Qt addin.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @aka000 How did you add the files? I'm wondering because this message "Its custom build command will be skipped" says that you have a custom build command for qtservice.cpp.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • A Offline
                A Offline
                aka000
                wrote on last edited by
                #7

                I just click on "include in project" in the solution explorer in VS, that always causes the .cpp file to be compiled.
                I now separated all declarations and definitions, creating a .h file and a .cpp file for each class. For some reason that works but of course it is not optimal...

                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