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. Static library linking

Static library linking

Scheduled Pinned Locked Moved General and Desktop
12 Posts 4 Posters 7.4k 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.
  • T Offline
    T Offline
    TheDestroyer
    wrote on last edited by
    #1

    Hello guys, :)

    I would like to link the libraries in my qmake file statically, especially for windows! I tried everything I know and I googled it, but the solutions I found didn't work. Could anyone tell me what's wrong with my qmake file?

    @

    #-------------------------------------------------

    Project created by QtCreator 2011-05-05T14:45:42

    #-------------------------------------------------

    QT += core gui
    QT += opengl

    DEPENDPATH += ../../libsrc
    INCLUDEPATH += ../../libsrc
    DEPENDPATH += ../../fft
    INCLUDEPATH += ../../fft

    TARGET = BlochSim
    TEMPLATE = app

    CONFIG += warn_off
    CONFIG += static

    SOURCES += main.cpp
    mainwindow.cpp
    glwidget.cpp
    systemsim.cpp
    ../NoiseGenerator/Noise.cpp
    ../../libsrc/param_obj.cpp
    ../../libsrc/Exception_sam_base.cpp
    openglobjects.cpp
    blochsim.cpp
    ../../fft/fft.cpp
    optionswidget.cpp

    HEADERS += mainwindow.h
    glwidget.h
    systemsim.h
    ../NoiseGenerator/Noise.h
    ../../libsrc/param_obj.h
    ../../libsrc/Exception_sam_base.cpp
    openglobjects.h
    blochsim.h
    ../../fft/fft.h
    optionswidget.h

    unix:LIBS += -lrt
    unix:LIBS += -lm
    unix:LIBS += -lpthread
    unix:LIBS += -lgsl
    unix:LIBS += -lgslcblas

    win32:DEPENDPATH += ../../libsrc/gsl/gsl-win-1.8
    win32:DEPENDPATH += ../../libsrc/gsl/gsl-win-1.8/lib
    win32:INCLUDEPATH += ../../libsrc/gsl/gsl-win-1.8/include

    win32:LIBS += -L../../libsrc/gsl/gsl-win-1.8/lib
    win32:LIBS += -L../../libsrc/gsl/gsl-win-1.8/bin
    win32:LIBS += -llibgsl
    win32:LIBS += -llibgslcblas

    @

    So after linking statically I expect to be able to execute the program just by having the executable run alone... but it keeps complaining that it doesn't find libgsl.dll. Any ideas?

    Thank you for any efforts :-)

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

      are you sure, you have a version of libgsl for static linking?

      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
      • T Offline
        T Offline
        TheDestroyer
        wrote on last edited by
        #3

        How can I know that?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          TheDestroyer
          wrote on last edited by
          #4

          I copied gsl libraries beside the executable, and I got an error with QtCored4.dll... which means, even Qt libraries are not statically linking!

          Any ideas?

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

            Have you made a complete build from the qt source package with static flag for configure?
            The qt distribution does not contain static libraries.

            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
            • T Offline
              T Offline
              TheDestroyer
              wrote on last edited by
              #6

              I'm using QtCreator. Doesn't it do that automatically if I set the correct flags in qmake?

              Does this mean that I always have to have QtCored.dll and some other dlls for Qt with my programs???

              1 Reply Last reply
              0
              • K Offline
                K Offline
                koahnig
                wrote on last edited by
                #7

                No, QtCreator does not generate static Qt libraries automatically.

                You have to compile Qt with static in configure as suggested by Gerolf.

                Even without the static libraries you do not need to have Qt dlls with your programs. Typically it is assumed that someone receiving your program has already Qt dlls installed.

                Vote the answer(s) that helped you to solve your issue(s)

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

                  If you install QtCreator, you have no libraries (it#s only the IDE)
                  If you install the SDK, you have the dlls you can use but not libraries for static linking. If you need static linking, please use the search on the forum and the wiki, there were many topics on that one. You have to build Qt for static linkage from the sources. Sorry, there is no other way for statically linked executables.

                  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
                  • T Offline
                    T Offline
                    TheDestroyer
                    wrote on last edited by
                    #9

                    Thank you. I'll see what I can do about it. :-)

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on last edited by
                      #10

                      Be aware of the licensing implications, when linking statically to Qt!

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        TheDestroyer
                        wrote on last edited by
                        #11

                        Could you please tell me about them? I'm using my programs for the university to create physics simulations!!! I'm not gonna sell them!!

                        1 Reply Last reply
                        0
                        • G Offline
                          G Offline
                          goetz
                          wrote on last edited by
                          #12

                          Have a look at the tag search, please:

                          • http://developer.qt.nokia.com/search/tag/license
                          • http://developer.qt.nokia.com/search/tag/licensing

                          The base line (I'm not a lawyer!) is, that you most probably have to GPL your code if you do static linking (except in case you use commercial license, of course).

                          http://www.catb.org/~esr/faqs/smart-questions.html

                          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