Results 1 to 10 of 10

Thread: how to use static library in qt4?

  1. #1
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Question how to use static library in qt4?

    Hi All,
    when compiling a demo of QT4:"browser"

    i got linking errors as below:

    webview.cpp.text+0x695): undefined reference to `QUiLoader::QUiLoader(QObject*)'
    webview.cpp.text+0x6cb): undefined reference to `QUiLoader::createWidget(QString const&, QWidget*, QString const&)'
    webview.cpp.text+0x6ed): undefined reference to `QUiLoader::~QUiLoader()'
    webview.cpp.text+0x718): undefined reference to `QUiLoader::~QUiLoader()'
    but i do specified uitools module when execute the qmake:

    qmake -project QT+=network QT+=webkit QT+=uitools

    I found the reason is due to in my qt library directory there is only a static library for uitools "libQtUiTools.a" and there is no "libQtUiTools.so".

    I make a link using:

    ln -s libQtUiTools.a libQtUiTools.so
    but it seems it doesn't help.

    how to use static library ,any suggestions?

    Thanks advance.
    hb

  2. #2
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Lightbulb Re: how to use static library in qt4?

    Hi ,

    Any ideas about it ?

    Any help would be highly appreciated!

    Best regards,
    hb

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: how to use static library in qt4?

    what happens if you just do 'qmake' and then 'make'?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. The following user says thank you to high_flyer for this useful post:

    hashb (28th October 2009)

  5. #4
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Default Re: how to use static library in qt4?

    Hi High_flyer,

    Thanks for your input,
    Here is my steps:
    $qmake -project QT+=network QT+=webkit QT+=uitools

    $qmake
    Project MESSAGE: Warning: unknown QT: uitools

    $make
    ...
    webview.cpp.text+0x695): undefined reference to `QUiLoader::QUiLoader(QObject*)'
    ....

    Best regards,
    hb

  6. #5
    Join Date
    Apr 2008
    Posts
    35
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to use static library in qt4?

    hb,

    there is no need for libQtUiTools.so for compiling, you should only need libQtUiTools.a when compiling or running.

    from the looks of the errors it looks like you are missing some declarations in header file or the project file...

    could you attach/paste the webview.cpp and the project file

    -Arpit

  7. The following user says thank you to arpspatel for this useful post:

    hashb (28th October 2009)

  8. #6
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Default Re: how to use static library in qt4?

    Hi Arpit,

    The source code can be found in the install path of QT4,

    $QTDIR/demos/browser

    BTW:
    It can link successfully if I add -lQtUiTools in Makefile :

    LIBS = .... .... .... -lQtUiTools

    but what confusing me is why
    qmake QT+=uitools ;qmake;make;
    cann't work

    Best regards,
    hb
    Last edited by hashb; 28th October 2009 at 05:43.

  9. #7
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Default Re: how to use static library in qt4?


  10. #8
    Join Date
    Dec 2008
    Location
    Paris, France
    Posts
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to use static library in qt4?

    but what confusing me is why
    qmake QT+=uitools ;qmake;make;
    cann't work
    According to the documentation, the project file should have CONFIG+=uitools (not QT+=uitools)
    See http://doc.trolltech.com/4.5/qtuitools.html

  11. The following user says thank you to daniel-verite for this useful post:

    hashb (28th October 2009)

  12. #9
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Default Re: how to use static library in qt4?

    Hi Daniel-verite,

    It works! !
    Thanks all very much !

    Best regards,
    hb

  13. #10
    Join Date
    Apr 2008
    Posts
    35
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to use static library in qt4?

    it would be easy to add CONFIG += uitools to project file if its not generated automatically..

Similar Threads

  1. QMAKE: Building static library without -fPIC
    By rainman110 in forum Qt Programming
    Replies: 1
    Last Post: 2nd May 2012, 17:07
  2. Extending a plugin in a static library
    By ultim8 in forum Qt Programming
    Replies: 5
    Last Post: 25th March 2010, 16:10
  3. Replies: 2
    Last Post: 7th September 2009, 22:13
  4. Compiling QCA as static library
    By NoRulez in forum Qt Programming
    Replies: 1
    Last Post: 7th December 2008, 18:32
  5. Replies: 16
    Last Post: 23rd May 2008, 11:12

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.