itsagoodquestion
Posts: 47
Joined: Sat Mar 05, 2016 10:30 pm

Compiled Qt 5.x/4.x static libs?

Wed Mar 09, 2016 1:41 pm

Hello pi'ers! I need to static compile my Qt code & having done it before on desktop I know it can get kind of hairy!! I was really hoping there's somewhere hosting Qt 4.x or 5.x precompiled ARM static libs that I can download? Please? :D

User avatar
topguy
Posts: 5627
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Compiled Qt 5.x/4.x static libs?

Fri Mar 11, 2016 11:39 am

Its unlikely that someone has done this. Why exactly do you need to staticly link it ?

itsagoodquestion
Posts: 47
Joined: Sat Mar 05, 2016 10:30 pm

Re: Compiled Qt 5.x/4.x static libs?

Fri Mar 11, 2016 1:17 pm

Of course they have, but I needed to compile anyways, took me 5 hours - https://theredblacktree.wordpress.com/2 ... -and-pi-2/

Why wouldn't I want to static compile? When I have to distro my program compiled dynamically the binaries will be 10-20 times the size of a static compile packed plus I get faster load times. For me Qt is basically useless unless it's static compiled.

User avatar
topguy
Posts: 5627
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Compiled Qt 5.x/4.x static libs?

Fri Mar 11, 2016 1:31 pm

I understand your argument but you can distribute only the libraries (.so files) that your application needs, together with your binary.

I'm also not sure if you comply with the GPL/LGPL license if you statically link, but unless you are developing a commercial product no-one will probably care.

itsagoodquestion
Posts: 47
Joined: Sat Mar 05, 2016 10:30 pm

Re: Compiled Qt 5.x/4.x static libs?

Fri Mar 11, 2016 2:34 pm

Yes but when I pack my Qt static compiled binary, it's around 2-3 MB, user runs ./QtApp and it runs - that's it.

When I distro all the dynamic libraries, it's around 30 MB, then I have to write an installer for the dynamical libraries and it just becomes a pain. I might as well write in Python or something for all that trouble!

You can publicly distro static compiled Qt apps if you either have purchased a Qt commercial license (which are very expensive, thousands of USD) or if your code is open source. I'm not doing public distro though.

User avatar
yasriady
Posts: 27
Joined: Wed Apr 08, 2015 2:37 am
Location: Indonesia
Contact: Website

Re: Compiled Qt 5.x/4.x static libs?

Sat Mar 19, 2016 4:10 am

Hi,
I used to work with Qt previously and quite satisfied with this very complete library. Linking statically is possible, but I think it will break licensing scheme, isn't it? Beside, with static linking will make binary code become bloat. Until I found awesome library, wxWidgets, very stable and complete lib either for GUI and nonGUI. Statically linking very possible and yields rather small and portable binary. And most important are about maturity, very well documentation and flexible licensing schema either for opensource or proprietary. Also the library is supported by large developer community and actively developed. Recent version is wxWidgets-3.1.0 released on 29-Feb-2016.

In some case to avoid version conflict with host library, I made static linking for libstdc++ and libgcc.
LDFLAGS="-static-libstdc++ -static-libgcc" as linker option will remove dependency to host libstdc++
Last edited by yasriady on Mon Mar 21, 2016 5:04 am, edited 4 times in total.
MyRaspberryPi : Cross Compile, wxWidgets/C++ and Linux Journal at http://yasriady.blogspot.com

User avatar
PeterO
Posts: 4882
Joined: Sun Jul 22, 2012 4:14 pm

Re: Compiled Qt 5.x/4.x static libs?

Sat Mar 19, 2016 8:12 am

itsagoodquestion wrote:When I distro all the dynamic libraries, it's around 30 MB, then I have to write an installer for the dynamical libraries and it just becomes a pain.
This is why packaging systems like apt https://wiki.debian.org/Apt were invented. You should learn how to use it.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

itsagoodquestion
Posts: 47
Joined: Sat Mar 05, 2016 10:30 pm

Re: Compiled Qt 5.x/4.x static libs?

Sat Mar 19, 2016 2:02 pm

PeterO wrote:
itsagoodquestion wrote:When I distro all the dynamic libraries, it's around 30 MB, then I have to write an installer for the dynamical libraries and it just becomes a pain.
This is why packaging systems like apt https://wiki.debian.org/Apt were invented. You should learn how to use it.

PeterO
This have nothing to do with static compile. Go look how big repository for Qt is in any package manager then come back and read question again please. But maybe I just go write everything in pygames, right? :lol: :lol: :lol: :lol: :lol:

yasriady - This is true, Qt static compiles are big, but when I UPX pack the binary it can get to around 3mb-ish (depending on what classes used). Static compiles don't break licensing terms but I like your suggestion about wxWidgets. I've heard of this for some years now and will look into it.

User avatar
yasriady
Posts: 27
Joined: Wed Apr 08, 2015 2:37 am
Location: Indonesia
Contact: Website

Re: Compiled Qt 5.x/4.x static libs?

Mon Mar 21, 2016 1:53 am

Sound good itsagoodquestion,

From my experience, upx-ed binary of wxWidgets yields me about 600KB for simple application, and arround 1MB-ish for more complex code... That's all depend on your purpose in deploying the program. Smaller cpu/ram such Raspberry Pi or upcoming C.H.I.P computer, sure... will be satisfied with this portable and slim application....

I made used of wxWidgets framework with following supported applications:
- wxWidgets-3.1.0
- RAD Tool using wxFormBuilder (very much helps in GUI and Form design)
- Compiler Gnu/GCC
- Eclipse-CPP (nice and full featured ide)


CMIW ..... / Yasriady
MyRaspberryPi : Cross Compile, wxWidgets/C++ and Linux Journal at http://yasriady.blogspot.com

User avatar
PeterO
Posts: 4882
Joined: Sun Jul 22, 2012 4:14 pm

Re: Compiled Qt 5.x/4.x static libs?

Mon Mar 21, 2016 8:23 am

itsagoodquestion wrote: This have nothing to do with static compile. Go look how big repository for Qt is in any package manager then come back and read question again please.
But it has everything to do with your problem. Why do you think you need to distribute and write installation scripts for Qt and other libraries yourself when apt-get does all that for you ?

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

itsagoodquestion
Posts: 47
Joined: Sat Mar 05, 2016 10:30 pm

Re: Compiled Qt 5.x/4.x static libs?

Tue Mar 22, 2016 6:33 pm

Peter,

sudo apt-get install QtCreator to run binary is very bad solution. Friend, I appreciate your want to help me but your information is wrong. Read this so u understand more.

http://stackoverflow.com/questions/9349 ... -for-linux
http://stackoverflow.com/questions/1134 ... e-with-lsb

Besides, my binary must be deployed to hundreds of embbeded devices that have much software installed, is not just for 1 youtube project. Is very important in our group effort for everyone's code to make no changes to operating system, if everyone on team starts "sudo apt-get install xxx" at 1st sight of problem then is anarchy on the OS and we all in trouble.

yasriady,

Sounds very nice, for me portability is big concern too. Normally I use notepad++ w/Qt plugin for Qt coding. Qt is very complicated w/compilation on linux because on Windows I make 1 x86 compile on XPsp1, and it run on every single version kernel/SP version, x86 or x64 up to Win10. On linux I have manually static compile for debian, for ubuntu, for armv6, armv7, etc. It takes days. I start some wxWidgets tutorials and I hope to find alternative, but the beauty and relative ease of animation of QtGraphicsScene/View is very difficult to beat. But thanks for info!!

User avatar
PeterO
Posts: 4882
Joined: Sun Jul 22, 2012 4:14 pm

Re: Compiled Qt 5.x/4.x static libs?

Tue Mar 22, 2016 10:30 pm

Top answer starts with "Shared libraries is the way to go"
One of the few answers says "Learn how to create packages for every distribution you want to target and create specific packages"

So you've already been told the same things as I'm telling you, yet you refuse to take any notice because it doesn't fit with your misguided view of the only correct solution !

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

itsagoodquestion
Posts: 47
Joined: Sat Mar 05, 2016 10:30 pm

Re: Compiled Qt 5.x/4.x static libs?

Wed Mar 23, 2016 3:20 am

my point is that there is no "sudo apt-get install qtdynamiclibs"... For me static compile is only solution. Millions on others Qt coders too. This why this option exists...

kora
Posts: 1
Joined: Wed Jun 22, 2016 3:33 pm

Re: Compiled Qt 5.x/4.x static libs?

Wed Jun 22, 2016 3:57 pm

After a few days of trying to cross compile Qt 5.7 I can clearly state this is the most painful library that I had to cross compile statically. It requires a lot of manual tinkering with their broken scripts. Buildroot doesn't support static build at all, yocto has only partial support. I would guess this is so painful because of Digia commercial boot2qt - qt for embedded product. Which I now really don't want to try.

The easiest way in the end is to build it on platform itself.

I see many haven't built anything for the embeeded to know why static libs are used to this day and why they are preffered in those cases, but here is from qt guys for you: http://blog.qt.io/blog/2016/05/25/fast- ... stem-image

And here is the latest on the commercial licence part:
http://stackoverflow.com/a/15322678/1176448

In any case, I did this as a part of my inquiry on their commercial embedded offerings. Since they are based on yocto I thought I should see what is there to offer. I'm disappointed with the result.

Do you want to purchase something that intentionally has this in their production code? Go dynamic route instead if it bothers you.

Code: Select all

if true; then ###[ '!' -f "$outpath/bin/qmake" ];


#           if which qmake >/dev/null 2>&1 && [ -f qmake/qmake.pro ]; then
#               (cd qmake && qmake) >/dev/null 2>&1 && continue
#           fi

Return to “C/C++”