Results 1 to 3 of 3

Thread: linking static libraries - standalone exe under windows

  1. #1
    Join Date
    May 2009
    Posts
    75
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question linking static libraries - standalone exe under windows

    Hallo,
    I have downloaded windows version of qt 5.5.1 - mingw.
    In the directory C:/Qt/5.5/mingw492_32/lib there are a lot of .a files, like libQt5Core.a and libQt5Gui.a, so, according to my opinion, I suppose to have the static lib installed. The dll files are located in C:\Qt\5.5\mingw492_32\bin

    I create a new "Qt application Project", and I modify .pro as follows:
    Qt Code:
    1. QT += core gui
    2.  
    3. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    4.  
    5. TARGET = prova
    6. TEMPLATE = app
    7.  
    8. QMAKE_LFLAGS += -static # try to link the static library
    9. QMAKE_LFLAGS += -Wl,-Map=prova.map # let's produce the map file
    10.  
    11. SOURCES += main.cpp\
    12. dialog.cpp
    13.  
    14. HEADERS += dialog.h
    15.  
    16. FORMS += dialog.ui
    To copy to clipboard, switch view to plain text mode 

    it seems tha all works. The linker command line is:
    Qt Code:
    1. g++ -static -Wl,-Map=prova.map -Wl,-subsystem,windows -mthreads -o debug\prova.exe debug/main.o debug/dialog.o debug/moc_dialog.o -lmingw32 -LC:/Qt/5.5/mingw492_32/lib -lqtmaind -lshell32 -lQt5Widgetsd -lQt5Guid -lQt5Cored
    To copy to clipboard, switch view to plain text mode 
    So it seems to use the right directory, and in the map file there are lines like:
    Qt Code:
    1. .text 0x00402c40 0x8 C:/Qt/5.5/mingw492_32/lib\libQt5Cored.a(d002900.o)
    2. 0x00402c40 QObject::timerEvent(QTimerEvent*)
    3. .text 0x00402c48 0x8 C:/Qt/5.5/mingw492_32/lib\libQt5Cored.a(d002895.o)
    4. 0x00402c48 QObject::childEvent(QChildEvent*)
    5. .text 0x00402c50 0x8 C:/Qt/5.5/mingw492_32/lib\libQt5Cored.a(d002902.o)
    6. 0x00402c50 QObject::customEvent(QEvent*)
    To copy to clipboard, switch view to plain text mode 

    So I thought that the exe was stand alone, but if I try to run it fails because it want libQt5Cored.dll.
    Why?
    Where am I wrong?

    best regards
    Max

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: linking static libraries - standalone exe under windows

    You write that you see libQt5Core.a, but do you have libQt5Cored.a?
    Maybe the static build is release only?

    Cheers,
    _

  3. #3
    Join Date
    May 2009
    Posts
    75
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Re: linking static libraries - standalone exe under windows

    there are both release and debug files:



    And I tried both debug and release build. but both seems to require dll's, so are dynamically linked.

    where am i wrong

    best regards
    Max
    Attached Images Attached Images

Similar Threads

  1. Replies: 4
    Last Post: 26th May 2014, 15:48
  2. Qt Standalone Application Static Linking?
    By awpitt13 in forum Qt Programming
    Replies: 1
    Last Post: 12th December 2013, 03:51
  3. Replies: 4
    Last Post: 21st July 2013, 23:06
  4. static and dynamic libraries linking
    By buddax2 in forum Newbie
    Replies: 2
    Last Post: 27th December 2010, 16:55
  5. Problem when linking with own static libraries
    By herveT in forum Qt Programming
    Replies: 4
    Last Post: 6th May 2009, 09:23

Tags for this Thread

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.