pbek / QOwnNotes

QOwnNotes is a plain-text file notepad and todo-list manager with Markdown support and Nextcloud / ownCloud integration.
https://www.qownnotes.org/
GNU General Public License v2.0
4.61k stars 410 forks source link

[FEATURE/QUESTION] Static linking #3067

Closed pa-0 closed 1 month ago

pa-0 commented 1 month ago

Is your feature request related to a problem? Please describe.

I'm currently contemplating building QownNotes into a statically-linked portable executable. I was not super familiar with Qt before, but I've been reading up on it. Note-worthy points (of which you are probably already aware):

  1. The tremendous amount of effort required that I am sure no one is interested in taking on when maintaining QownNotes is a challenge all by its lonesome. Successfully building Qownnotes with all of its libraries / dependencies statically-linked is probably not worth the potential performance gains. I fully appreciate the time/effort required are disproportionate compared to any perceived benefit... and the likelihood of failure πŸ˜„
  2. License considerations There are some legal implications with distributing a statically-linked application built with qt that can complicate things.

All of this in mind, I'd still like to try to take it on. With respect to point 1, let's call it part-learning experience, part-masochism on my part. As for any issues with licensing, my thoughts are that I could figure out how to simplify the process as much as possible (via GitHub workflow most likely) and document the steps for anyone who would like to build it for themselves. This way I avoid violating any licensing terms. If you are interested, I'd be happy to share those docs/scripts with you once I've 'perfected' them.

My question for you: How much revision of the source code / project files would I need to do to get to a place where a build should theoretically succeed (beyond of course building QT static from the source as a prerequisite)?

Describe the solution you'd like

A clear and concise description of what you want to happen.

Describe alternatives you've considered

Additional context

pbek commented 1 month ago

Phew, if you manage to build Qt statically it might be ok. Which platform do you want to build for and what are you trying to achieve?

pbek commented 1 month ago

If it's just portability... There is the portable mode.

pa-0 commented 1 month ago

For now, it's just an experiment, for the sake of learning how / seeing if I can do it. Of course, I recognize there's probably no benefit in doing this -- maybe marginal performance gains on cold-opening the app, but I will benchmark /compare if I manage to get it working.

Beyond that, part-OCD, part-my weird fascination with having applications in the form of single binaries that run with little to no dependencies (save for maybe the runtime).

pbek commented 1 month ago

I don't think this will be a fun endeavor, and it depends a lot on the platform you want to build for. Please let me know how it went. 😁

Btw. QOwnNotes has no external dependencies but Qt.

pa-0 commented 1 month ago

Windows 11 64-bit and before you say anything I realize that's probably the worst of the main three! πŸ˜† Am I going to have to revise the .pro files or do QT tools automate most of that once I've built the qt source statically?

pbek commented 1 month ago

A little bit, see https://wiki.qt.io/Build_Standalone_Qt_Application_for_Windows.

pa-0 commented 1 month ago

Thanks. Will report back with positive results... if any πŸ€·πŸ½β€β™‚οΈ

pbek commented 1 month ago

Have fun πŸ˜‰

pa-0 commented 1 month ago

Quick question: I notice in the documentation, you advise that only mingw toolchain should be used to compile, but in the Build logs^1, it looks like you're using VS. Are the docs up to date or have circumstances changed since that was written?

pbek commented 1 month ago

Those runs are from a PR, @Waqar144 is currently playing around with Microsoft's tool chain.

pa-0 commented 1 month ago

Yes sorry I should have followed up. I noticed the latest PR after asking about that. Good luck!

pa-0 commented 1 month ago
**Question:** I am trying to build Qt from its source as minimally as possible. The build instructions say that `qtwebsockets` and `qt5compat` are the only additional modules needed. Does that mean that I skip pretty much every single one of these (below)? I realize the answer is _probably_ an obvious "yes, you can", but I just want to be sure I am understanding correctly before wasting time building it. Some of these seem like they would be relevant (e.g., `qtconnectivity`, `qttranslations`, `qtsvg`, etc.). Maybe, I am just not great at navigating the documentation, but qt docs seem to be a bit lacking in my opinion.
-skip qt3d                         -skip qtandroidextras           -skip qtcanvas3d \
-skip qtcharts                     -skip qtconnectivity            -skip qtdatavis3d \
-skip qtdeclarative                -skip qtdoc                     -skip qtgamepad \
-skip qtgraphicaleffects           -skip qtimageformats            -skip qtlocation \
-skip qtmacextras                  -skip qtmultimedia              -skip qtnetworkauth \
-skip qtpurchasing                 -skip qtquickcontrols           -skip qtquickcontrols2 \
-skip qtscript                     -skip qtscxml                   -skip qtsensors \
-skip qtserialbus                  -skip qtserialport              -skip qtspeech \
-skip qtsvg                        -skip qttools                   -skip qttranslations \
-skip qtvirtualkeyboard            -skip qtwayland                 -skip qtwebchannel \
-skip qtwebengine                  -skip qtwebview                 -skip qtwinextras \
-skip qtx11extras                  -skip qtxmlpatterns

Also, any idea how these features fit into the equation?

-no-feature-texthtmlparser       -no-feature-textodfwriter          -no-feature-concurrent \
-no-feature-effects              -no-feature-sharedmemory           -no-feature-systemsemaphore \
-no-feature-im                   -no-feature-process                -no-feature-dom \
-no-feature-filesystemmodel      -no-feature-filesystemwatcher      -no-feature-graphicsview \
-no-feature-graphicseffect       -no-feature-sizegrip               -no-feature-calendarwidget \
-no-feature-printpreviewwidget   -no-feature-keysequenceedit        -no-feature-colordialog \
-no-feature-filedialog           -no-feature-fontdialog             -no-feature-printpreviewdialog \
-no-feature-progressdialog       -no-feature-inputdialog            -no-feature-errormessage \
-no-feature-wizard               -no-feature-datawidgetmapper       -no-feature-imageformat_bmp \
-no-feature-imageformat_ppm      -no-feature-imageformat_xbm        -no-feature-imageformat_png \
-no-feature-imageformat_jpeg     -no-feature-image_heuristic_mask   -no-feature-image_text \
-no-feature-colornames           -no-feature-cups                   -no-feature-paint_debug \
-no-feature-freetype             -no-feature-translation            -no-feature-codecs \
-no-feature-big_codecs           -no-feature-iconv                  -no-feature-ftp \
-no-feature-udpsocket            -no-feature-networkproxy           -no-feature-socks5 \
-no-feature-networkdiskcache     -no-feature-bearermanagement       -no-feature-completer \
-no-feature-fscompleter          -no-feature-desktopservices        -no-feature-mimetype \
-no-feature-systemtrayicon       -no-feature-undocommand            -no-feature-undostack \
-no-feature-undogroup            -no-feature-undoview               -no-feature-statemachine \
-no-feature-gestures             -no-feature-dbus
pa-0 commented 1 month ago

Also just FYI, I absolutely appreciate how these questions (treating you like qt support) can get incredibly annoying astonishingly fast, so just want to make clear that I will most definitely curb this behavior / refrain from asking anything outside of a narrower QOwnNotes-related scope moving forward 🀣

pa-0 commented 1 month ago

NEVERMIND figured it out. It was actually much simpler than I anticipated (and dreadfully obvious):

QT       += core gui widgets sql svg network xml printsupport qml websockets concurrent

I see qt5compat is no longer required. That's pretty cool. Also much of the documentation I am realizing is irrelevant at this point as QT has deprecated some of the long-standing parameters that used to be standard for configuring the source, e.g. -opensource is now ignored, or at least soon will be. Caught a bunch of little nuances like this

pbek commented 1 month ago

I see qt5compat is no longer required.

That's right, actually it wasn't for quite a while, but never removed.