simple-mail icon indicating copy to clipboard operation
simple-mail copied to clipboard

How to build statically with Qt 5.12.11?

Open joshorenberg opened this issue 3 years ago • 13 comments

Thanks for the awesome project dantti. Do you happen to know how to build the libraries statically with Qt 5.12.11 (the main relevant part being Qt 5)? I only have QMake.exe to work with in the qt static build dir. I have scoured the web looking for solutions but haven't been able to find anything that works yet. I can build my program statically but as it is now it depends on Qt5Core.dll and Qt5Network.dll when using the simple-mail library. Ideally I would like a static build without dlls. Thanks again!

joshorenberg avatar Sep 20 '22 23:09 joshorenberg

https://github.com/cutelyst/simple-mail/blob/master/CMakeLists.txt#L21

dantti avatar Sep 20 '22 23:09 dantti

Awesome thanks for the quick reply, will try.

joshorenberg avatar Sep 20 '22 23:09 joshorenberg

Still no luck, tried 4 separate builds one with Qt Creator using 5.15.2 and another using Qt Creator with 5.12.11. My static build is from 5.12.11. I both edited the CMakeLists.txt file as recommended and setting BUILD_SHARED_LIBS to off in the CMake configuration section of build settings for the project. Obviously after building the library I compiled my program statically. It's still asking for both SimpleMail2Qt5.dll and when that's present Qt5Core.dll and Qt5Network.dll. There's gotta be something simple I'm overlooking, any ideas? Should I try building outside of Qt Creator? Thanks for the help!

joshorenberg avatar Sep 26 '22 23:09 joshorenberg

you should not edit the cmake file, instead tell cmake the option, QtCreator lists all of them

dantti avatar Sep 27 '22 00:09 dantti

Still no luck, unmodified CMakeLists.txt and told Qt Creator to turn off BUILD_SHARED_LIBS. The static .lib file should be bigger than the shared .lib file right? I built it 5 times same size each time and my silly program is still barking at me. Either I'm cursed and in need of an exorcism or I'm a babbling idiot who can't figure this out :) Any ideas? On my laptop with Qt Creator & 5.12.11 Cmake didn't come bundled with the Qt install so I've been using MSVS Cmake for it on the laptop. Also on my desktop with Qt Creator & 5.15.2 Cmake came bundled so I've been using the bundled one but still get the same problems.

joshorenberg avatar Sep 27 '22 20:09 joshorenberg

Another caveat ... the laptop has MSVS 2019 installed but Qt 5.12.11 uses MSVS 2017... shouldn't matter right?

joshorenberg avatar Sep 27 '22 20:09 joshorenberg

Sorry I'm no Windows expert, regarding the compiler it could be an issue the other way around.

dantti avatar Sep 27 '22 20:09 dantti

I actually just built from the command-line with -DBUILD_SHARED_LIBS=OFF then built the library using MSVS and it's the exact same size for both the dll and the lib file as before. I assume it should be bigger when including the Qt code for a static library right? I might seek help on stack overflow. Thanks!

joshorenberg avatar Sep 27 '22 20:09 joshorenberg

No building simple-mail in static mode builds simple-mail in static mode. To include Qt you would need to build Qt in static mode.

dantti avatar Sep 27 '22 21:09 dantti

Actually even with Qt in static mode it would not be included in simple-mail static libs, only on simple-mail demos (if built)

dantti avatar Sep 27 '22 21:09 dantti

As it is now the statically built program runs fine without any dlls unless I include the simplemail library, then it asks for SimpleMail2Qt5.dll and if that's there then it asks for Qt5Core.dll and Qt5Network.dll. Not sure how the compilation works for that.

joshorenberg avatar Sep 27 '22 21:09 joshorenberg

  • unless I include the simplemail library and email code in the program *

joshorenberg avatar Sep 30 '22 00:09 joshorenberg

Any complications with setting up cutelyst simplemail as a pri project?

joshorenberg avatar Sep 30 '22 03:09 joshorenberg

Finally figured this guy out, see here.

joshorenberg avatar May 31 '23 19:05 joshorenberg

Fixed by https://github.com/cutelyst/simple-mail/commit/759d40e5ee713be76b5c272019b52605dcd46897

dantti avatar Oct 26 '23 19:10 dantti