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. Statlic linking of Qt and C++ libraries
QtWS25 Last Chance

Statlic linking of Qt and C++ libraries

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 8.5k Views
  • 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.
  • S Offline
    S Offline
    soroush
    wrote on last edited by
    #1

    Hi

    I'm writing a program using Qt and libstd++. target machine probably does not have any of them installed. I would like to statically link all Qt and other c++ libraries used in my application. Adding CONFIG += static into the .pro file didn't help.

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      You have to build Qt itself as a static library. Check out the help for the configure script of Qt fo rmore info but you will at least need to use the -static option when configuring Qt.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • S Offline
        S Offline
        soroush
        wrote on last edited by
        #3

        I have installed Qt from Ubuntu repository. Could you tell me please how do I statically re-compile Qt? I have to install Qt development files?

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #4

          Yes download the qt-everywhere source tarball from "here":http://qt.nokia.com/downloads/linux-x11-cpp. Then extract it somewhere, configure it with something like:

          @./configure -static -prefix $HOME/development/qt-static-4.7.2@

          Then make and make install as per usual.

          Once that is done, simply use the version of qmake that gets installed rather than the system-supplied qmake. You can do this by editing your $PATH environment variable to pick up your new qmake first or you could set up and alias or just use the full path to it.

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • S Offline
            S Offline
            soroush
            wrote on last edited by
            #5

            Ok, I'm going to download and compile.

            Thank you.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              soroush
              wrote on last edited by
              #6

              Ok, I'm unable to compile Qt ! my download failed last day (when I moved my notebook from university to home :-( and I have to redownload it.

              Currently I have installed qt-sdk 64-bit version from repositories. Is there a way to link shared libraries like as static libraries? I also have to compile a 32-bit program :-) I'm looking for a way to avoid download and compile...

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                ZapB
                wrote on last edited by
                #7

                I thought that the sdk shipped the sources along with it? Just build those if you already have them to hand. You can rebuild and install in as many configurations as you like. The same source tree applies to all.

                Nokia Certified Qt Specialist
                Interested in hearing about Qt related work

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  soroush
                  wrote on last edited by
                  #8

                  There are header files in /usr/include/qt4 directory. But there are no any configuration or make or even source codes. I don't know if they are correct sources or not, or if I will be able to revert them to previous state or not. think there are just headers and compiled libraries included in packages.

                  I'm going to download the source code.

                  Thanks you :-)

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    giesbert
                    wrote on last edited by
                    #9

                    If you download the SDK beta (and I think also RC) the structure is changed :-)
                    You have the headers without links, no sources inside. You can also download / install the sourc4s with the installer, but it is different from the pure source package where the include files from include point to the sources dir.

                    To rebuild Qt, you now have to download the real source zip or tar file.

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      soroush
                      wrote on last edited by
                      #10

                      bq. ./configure -static -prefix $HOME/development/qt-static-4.7.2

                      I tested my program in target machine. It works!

                      Thanks in advance :-)

                      1 Reply Last reply
                      0
                      • Z Offline
                        Z Offline
                        ZapB
                        wrote on last edited by
                        #11

                        Congratulations! Good luck with the rest of your project.

                        Nokia Certified Qt Specialist
                        Interested in hearing about Qt related work

                        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