Results 1 to 4 of 4

Thread: statically link Qt libraries (not build static library)

  1. #1
    Join Date
    Nov 2009
    Location
    San Antonio, TX
    Posts
    69
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt Jambi
    Platforms
    Unix/X11 Windows

    Default statically link Qt libraries (not build static library)

    I am currently working under linux, but eventually will need to so this in Windows.

    I have seen many posts about statically linking Qt libraries, which turn out to be building static Qt library versions. I already have both the static and shared libraries. What is the magic in the '.pro' file to have qmake produce a Makefile that statically links the Qt libraries? And do this automatically.

    If I modify the Makefile by hand and add '-Xlinker -Bstatic' before all the -lQt... and '-Xlinker -Bdynamic' after them, then the build process produces an app with statically linked Qt libraries.

    And please do not tell me CONFIG items -static and -staticlib. From what I can see, they are for building a static library.

    I haven't worked in Windows for a number of year, but I assume all that needs to be done there is choose the '.lib' files for the project since it does use the '.pro' file . . . even though it is based on it to start. It would be nice to be able to use one '.pro' file, though.

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: statically link Qt libraries (not build static library)

    Add

    Qt Code:
    1. QMAKE_LFLAGS += -Xlinker -Bstatic
    To copy to clipboard, switch view to plain text mode 

    or

    Qt Code:
    1. QMAKE_LFLAGS = -Xlinker -Bstatic $$QMAKE_LFLAGS
    To copy to clipboard, switch view to plain text mode 

    to your project file.

    Check the qmake manual for more information.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Nov 2009
    Location
    San Antonio, TX
    Posts
    69
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt Jambi
    Platforms
    Unix/X11 Windows

    Default Re: statically link Qt libraries (not build static library)

    adding -Xlinker command to QMAKE_LFLAGS does get it a step further, but that tries to statically link all libraries.

    I just need the Qt libraries boxed with -Bstatic and -Bdynamic. The following

    LIBS = $(SUBLIBS) -L/usr/lib/qt45/lib -L/usr/X11R6/lib -lutil -lQtOpenGL -L/usr/lib/qt45/lib -L/usr/X11R6/lib -pthread -pthread -pthread -pthread -pthread -pthread -pthread -pthread -lQtGui -pthread -lpng -lfreetype -lSM -lICE -pthread -pthread -lXi -lXrender -lXrandr -lXcursor -lXinerama -lfontconfig -lXext -lX11 -lQtNetwork -pthread -pthread -lQtCore -lz -lm -pthread -lgthread-2.0 -lglib-2.0 -lrt -ldl -lGLU -lGL -lpthread

    changed to

    LIBS = $(SUBLIBS) -L/usr/lib/qt45/lib -L/usr/X11R6/lib -lutil -Xlinker -Bstatic -lQtOpenGL -Xlinker -Bdynamic -L/usr/lib/qt45/lib -L/usr/X11R6/lib -pthread -pthread -pthread -pthread -pthread -pthread -pthread -pthread -Xlinker -Bstatic -lQtGui -Xlinker -Bdynamic -pthread -lpng -lfreetype -lSM -lICE -pthread -pthread -lXi -lXrender -lXrandr -lXcursor -lXinerama -lfontconfig -lXext -lX11 -Xlinker -Bstatic -lQtNetwork -Xlinker -Bdynamic -pthread -pthread -Xlinker -Bstatic -lQtCore -Xlinker -Bdynamic -lz -lm -pthread -lgthread-2.0 -lglib-2.0 -lrt -ldl -lGLU -lGL -lpthread

    Not a biggee, but it would nice if qmake would cut down on the libraries inclusions ( I know I need pthread but that many times :-) )

  4. #4
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: statically link Qt libraries (not build static library)

    Maybe you need to muck about with the QMAKE_LIBS_* variables then. Be creative
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. How can i build an app statically?
    By srohit24 in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2010, 09:38
  2. How to link static libraries --- in .pro file settings?
    By jiapei100 in forum Qt Programming
    Replies: 1
    Last Post: 7th January 2010, 16:39
  3. Replies: 2
    Last Post: 7th September 2009, 21:13
  4. Link all Qt libs statically.
    By psih128 in forum Installation and Deployment
    Replies: 12
    Last Post: 29th December 2008, 20:48
  5. How can I build <<hello world>> example statically
    By krivenok in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2006, 15:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.