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. Problems to compile a static library project
Forum Updated to NodeBB v4.3 + New Features

Problems to compile a static library project

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 2.0k 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.
  • J Offline
    J Offline
    jhx76
    wrote on last edited by
    #1

    Hi all,
    I am new on this forum, and don't know if the post is at the good place. Let me know if i am wrong writing in this section.

    Today, i want to compile a static library with Qt. I started with a light sample code. I have a single class containing a QString attribute.
    When i compile this little project, i get a single error :
    QString : no such file or directory

    I really don't know why this error happened. I also trie to add QT += core to the .pro file with no more result.

    Here is the sample code :
    @
    #ifndef SAMPLELIBRARY_H
    #define SAMPLELIBRARY_H
    #include <QString>
    class SampleLibrary
    {
    private:
    QString s;
    public:
    SampleLibrary();
    };
    #endif
    @
    @
    #include "SampleLibrary.h"
    SampleLibrary::SampleLibrary()
    {
    }
    @

    And the .pro file :
    @
    QT -= gui
    TARGET = SampleLibrary
    TEMPLATE = lib
    CONFIG = staticlib
    SOURCES += SampleLibrary.cpp
    HEADERS += SampleLibrary.h
    @

    Someone here could help to resolve it ?
    Regards,
    Jhx76

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MarianMMX
      wrote on last edited by
      #2

      Remove
      #include <QString>
      and

      bq. add QT += core to the .pro

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        [quote author="MarianMMX" date="1384286077"]Remove
        #include <QString>
        [/quote]

        Why remove the include ? How would he be able to use QString in that case ?

        What OS. Qt version and IDE are you using ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jhx76
          wrote on last edited by
          #4

          Hi, thanks for your replies. I am using ubuntu 13.04 and Qt4.8.5.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            And how do you build your library ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • J Offline
              J Offline
              jhx76
              wrote on last edited by
              #6

              Hi guys,
              Sorry, i am late to reply ...

              To build the library, i just created a C++ Library project with QtCreator (the last version avaible).
              I added the "CONFIG = staticlib" to the project file to specify i want to build it as a static library (was configured to build a dynamic one into .so files).

              The library provides many classes to support the xPL protocol (see http://xplproject.org.uk fore more informations about xPL project).
              Face to the difficulties i encountered to build it, i sarted a "test project", that i linked you in the above messages.
              I tried to build it from QtCreator.

              I also tried to add
              @
              QT += core
              @
              to the project file, but it doesn't fix the problem.

              Thank you very much for your replies.
              Have a good evening ! :)
              Jhx76

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jhx76
                wrote on last edited by
                #7

                Hi again !

                I just found my error !
                I had to change :
                @
                CONFIG = staticlib
                @

                into
                @
                CONFIG += staticlib
                @

                And it performs the build correctly ! :)
                Thanks for help
                Jhx76

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Ok, I see what your problem was.

                  CONFIG contains already a base set of values. Using = you emptied it thus removing qt from it so it would use it to build your library

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  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