Results 1 to 12 of 12

Thread: How to statically compile my project with Qt on Linux

  1. #1

    Default How to statically compile my project with Qt on Linux

    I would like to statically compile my project with Qt on Linux, how should I do?

    I used the command:
    Qt Code:
    1. ./configure -static -release -qt-zlib -qt-gif -qt-libpng -qt-libmng -qt-libjpeg -nomake demos -nomake examples -qt-sql-sqlite -prefix /usr/local/Trolltech/Qt-4.7.3-static
    2. make
    3. make install
    To copy to clipboard, switch view to plain text mode 

    then what should I do? Thanks!

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

    Default Re: How to statically compile my project with Qt on Linux

    I used the command:
    And?
    What are the results?

    This command should build a static Qt lib, which you need if you want to build your application with Qt statically.
    Now you need to build your project and link to the static Qt lib which you just built with above command.
    ==========================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.

  3. #3

    Default Re: How to statically compile my project with Qt on Linux

    My project (I compiled it dynamically successfully before) is located at /mnt/hgfs/VBox_Shared/SeaTools, then:

    Qt Code:
    1. cd /mnt/hgfs/VBox_Shared/SeaTools
    2. make
    To copy to clipboard, switch view to plain text mode 

    but cannot continue. Then add
    Qt Code:
    1. QMAKE_LFLAGS += -static
    To copy to clipboard, switch view to plain text mode 
    after
    Qt Code:
    1. TEMPLATE = app
    2. TARGET =
    3. DEPENDPATH += . debug include release translations
    4. INCLUDEPATH += . include
    5. QT += network
    To copy to clipboard, switch view to plain text mode 

    I got error results:
    Qt Code:
    1. mike@mike-desktop:/mnt/hgfs/VBox_Shared/SeaTools$ make
    2. /usr/bin/uic-qt4 calccrcdialog.ui -o ui_calccrcdialog.h
    3. /usr/bin/uic-qt4 chooseareadialog.ui -o ui_chooseareadialog.h
    4. /usr/bin/uic-qt4 choosedatadialog.ui -o ui_choosedatadialog.h
    5. /usr/bin/uic-qt4 choosezftabdialog.ui -o ui_choosezftabdialog.h
    6. /usr/bin/uic-qt4 comsetdialog.ui -o ui_comsetdialog.h
    7. /usr/bin/uic-qt4 downloaddialog.ui -o ui_downloaddialog.h
    8. /usr/bin/uic-qt4 grouptestdialog.ui -o ui_grouptestdialog.h
    9. /usr/bin/uic-qt4 inputdialog.ui -o ui_inputdialog.h
    10. /usr/bin/uic-qt4 logindialog.ui -o ui_logindialog.h
    11. /usr/bin/uic-qt4 mainwindow.ui -o ui_mainwindow.h
    12. /usr/bin/uic-qt4 settimedialog.ui -o ui_settimedialog.h
    13. /usr/bin/uic-qt4 transfiledialog.ui -o ui_transfiledialog.h
    14. /usr/bin/uic-qt4 transfiledialog_js.ui -o ui_transfiledialog_js.h
    15. /usr/bin/uic-qt4 uploaddialog.ui -o ui_uploaddialog.h
    16. /usr/bin/uic-qt4 usrmanagedialog.ui -o ui_usrmanagedialog.h
    17. g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -Iinclude -I. -I. -o addgrptabledelegate.o addgrptabledelegate.cpp
    18. g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -Iinclude -I. -I. -o calccrcdialog.o calccrcdialog.cpp
    19. ......
    20. ......
    21. ......
    22. moc_inputtabledelegate.o moc_jctabledelegate.o moc_logindialog.o moc_mainwindow.o moc_myclient.o moc_myfileprocess.o moc_nodetabledelegate.o moc_othertabledelegate.o moc_pointtabledelegate.o moc_porttabledelegate.o moc_settimedialog.o moc_supporttabledelegate.o moc_transfileclient.o moc_transfileclient_js.o moc_transfiledelegate.o moc_transfiledelegate_js.o moc_transfiledialog.o moc_transfiledialog_js.o moc_transmittabledelegate.o moc_uploaddialog.o moc_usrmanagedialog.o moc_zftabledelegate.o qrc_seatools.o -L/usr/lib -lQtGui -lQtNetwork -lQtCore -lpthread
    23. /usr/bin/ld: cannot find -lQtGui
    24. collect2: ld returned 1 exit status
    25. make: *** [SeaTools] Error 1
    26. mike@mike-desktop:/mnt/hgfs/VBox_Shared/SeaTools$
    To copy to clipboard, switch view to plain text mode 

    Or I modified Makefile by:
    Qt Code:
    1. CXXFLAGS = -static -pipe -Wall -W -O2 -fomit-frame-pointer -pipe -march=i586 -mcpu=pentiumpro -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT
    To copy to clipboard, switch view to plain text mode 
    and got similar error results.

  4. #4
    Join Date
    Sep 2011
    Posts
    1,245
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to statically compile my project with Qt on Linux

    what is the location of yuor static qt libs?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5

    Default Re: How to statically compile my project with Qt on Linux

    /usr/locat/Trolltech/Qt-4.7.3-static/lib

    I add
    Qt Code:
    1. export QTDIR=/usr/local/Trolltech/Qt-4.7.3-static
    2. export PATH=$QTDIR/bin:$PATH
    3. export MANPATH=$QTDIR/man:$MANPATH
    4. export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
    To copy to clipboard, switch view to plain text mode 
    at the bottom of /etc/profile

    /usr/locat/Trolltech/Qt-4.7.3-static/lib

    I add
    Qt Code:
    1. export QTDIR=/usr/local/Trolltech/Qt-4.7.3-static
    2. export PATH=$QTDIR/bin:$PATH
    3. export MANPATH=$QTDIR/man:$MANPATH
    4. export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
    To copy to clipboard, switch view to plain text mode 
    at the bottom of /etc/profile

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

    Default Re: How to statically compile my project with Qt on Linux

    you are building a debug project and linking to a release Qt lib.
    ==========================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.

  7. #7

    Default Re: How to statically compile my project with Qt on Linux

    Quote Originally Posted by high_flyer View Post
    you are building a debug project and linking to a release Qt lib.
    How did you know it? I am a newbie. And what shall I do next? Thanks.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to statically compile my project with Qt on Linux

    Quote Originally Posted by pellyhawk View Post
    /usr/locat/Trolltech/Qt-4.7.3-static/lib

    I add
    Qt Code:
    1. export QTDIR=/usr/local/Trolltech/Qt-4.7.3-static
    2. export PATH=$QTDIR/bin:$PATH
    3. export MANPATH=$QTDIR/man:$MANPATH
    4. export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
    To copy to clipboard, switch view to plain text mode 
    at the bottom of /etc/profile

    /usr/locat/Trolltech/Qt-4.7.3-static/lib

    I add
    Qt Code:
    1. export QTDIR=/usr/local/Trolltech/Qt-4.7.3-static
    2. export PATH=$QTDIR/bin:$PATH
    3. export MANPATH=$QTDIR/man:$MANPATH
    4. export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
    To copy to clipboard, switch view to plain text mode 
    at the bottom of /etc/profile
    You can see in your compilation log that you are using Qt located in /usr/ and not in /usr/local/Trolltech/Qt-4.7.3-static.

    What does qmake -v return?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: How to statically compile my project with Qt on Linux

    How did you know it?
    That is what you configured.
    When building Qt:
    ./configure -static -release
    Actually I am not sure if your project build is just debug both debug and release.
    Try putting this in your projects *.pro file:
    CONFIG = release

    In addition, I see your lib search path for your porject is not correct:
    -L/usr/lib
    Try adding
    LIBS += -L/usr/local/Trolltech/Qt-4.7.3-static/lib
    ==========================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.

  10. #10

    Default Re: How to statically compile my project with Qt on Linux

    Quote Originally Posted by wysota View Post
    You can see in your compilation log that you are using Qt located in /usr/ and not in /usr/local/Trolltech/Qt-4.7.3-static.

    What does qmake -v return?
    mike@mike-desktop:/lib$ qmake -v
    QMake version 2.01a
    Using Qt version 4.7.3 in /usr/local/Trolltech/Qt-4.7.3-static/lib

    Is this is the location of static Qt lib?
    Last edited by pellyhawk; 2nd July 2012 at 14:54.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to statically compile my project with Qt on Linux

    Good. So now cd to the directory containing your project, run qmake and only then run make.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12

    Default Re: How to statically compile my project with Qt on Linux

    Quote Originally Posted by high_flyer View Post
    That is what you configured.
    When building Qt:


    Actually I am not sure if your project build is just debug both debug and release.
    Try putting this in your projects *.pro file:
    CONFIG = release

    In addition, I see your lib search path for your porject is not correct:
    -L/usr/lib
    Try adding
    LIBS += -L/usr/local/Trolltech/Qt-4.7.3-static/lib
    Yes, I add "CONFIG = release" at .pro file.
    Qt Code:
    1. TEMPLATE = app
    2. TARGET =
    3. DEPENDPATH += . debug include release translations
    4. INCLUDEPATH += . include
    5. QT += network
    6. CONFIG += static
    To copy to clipboard, switch view to plain text mode 
    Do I add it right?

    And I add "LIBS += -L/usr/local/Trolltech/Qt-4.7.3-static/lib" at .pro or Makefile?

    You told me that "lib search path for your porject is not correct". Do found it by "g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -Iinclude -I. -I. -o addgrptabledelegate.o addgrptabledelegate.cpp" (SHARED???)

    Thanks.

Similar Threads

  1. how to compile phonon-backend statically on linux?
    By berlinud in forum Installation and Deployment
    Replies: 2
    Last Post: 27th August 2010, 18:06
  2. how to statically compile a program with qt libs?linux platform
    By berlinud in forum Installation and Deployment
    Replies: 8
    Last Post: 27th August 2010, 16:38
  3. Compile Qt for Mac statically
    By eric in forum Installation and Deployment
    Replies: 4
    Last Post: 19th August 2008, 15:45
  4. Project won't compile under Windows (works under Linux)
    By philski in forum Qt Programming
    Replies: 7
    Last Post: 14th September 2006, 15:29
  5. Qt 4.1 - compile regular DLL statically
    By Elder Orb in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2006, 09:28

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.