0

Hello I trying to do static linking in QT in Linux OpenSUSE 42.3 but I get some problems https://doc.qt.io/qt-5.6/linux-deployment.html I use this instruction and searching qt in pc(I installed qt creator,qt5 des.,qt5 ass.,qt5 D-Bus viewer), and i get many variants(4xQT,QT5,QT5CORE and etc), i try to find somewhere configure file ( which run in instruction ./configure -static -prefix /path/to/Qt , but i get nothing) , also i find linuxdeployqt which can create executable file(AppImage), so what to use linuxdeployqt (AppImage) or QT static linking still worth wasting my time?What the difference?

HERT
  • 63
  • 8
  • Have you compiled Qt in a static way? – eyllanesc Mar 21 '18 at 20:05
  • No, i can't compile. – HERT Mar 21 '18 at 20:19
  • if you want to statically link the Qt library, it must be compiled in a static way, many OS do not do it, and only compile it dynamically, so in your case you can not do it, you must download the Qt source code and compile it in a static way, and you can just do it. – eyllanesc Mar 21 '18 at 20:21
  • I was thinking you talk about static link, I can run my program in QT creator and program work perfect. – HERT Mar 21 '18 at 20:24
  • Obviously it works correctly since that executable is linking the libraries in a dynamin form, since it will be found in `/usr/lib`, for example, execute `ldd your_executable` and observe the dependencies. – eyllanesc Mar 21 '18 at 20:27

1 Answers1

0

Welcome to Qt world !

You have to understand the Qt installation in two ways.

1) Dynamic library ( Shared lib in linux ) using Qt online/offline installer or some lib are already there in most of Linux OS.

2) Static library ( Static lib in linux ) using Qt source code and then do the manual configuration using ./configure with multiple options.

Your problem is pretty straight forward to solve if you understood it correctly how to install Qt with static linking in your Linux OS.

Now check this link http://www.linuxfromscratch.org/blfs/view/svn/x/qt5.html

here they have provided step by step instruction to download Qt source and configure options.

Now for you important parameter is -- "static"

./configure -prefix $QT5PREFIX \ -sysconfdir /etc/xdg \ -confirm-license \ -opensource \ -static \ -dbus-linked \ -openssl-linked \ -system-harfbuzz \ -system-sqlite \ -nomake examples \ -no-rpath \ -skip qtwebengine &&

which I have added for you and highlighted.

Kindly share what you want to achieve exactly with this cause static compilation is only beneficial in case you commercial license of Qt other wise if you want to go for open source version then you must to choose dynamic library deployment ... check licensing part ...

if you need in dynamic deployment let's reframe your question with exact requirement.