On 8/28/2021 3:02 AM, Ben Cottrell wrote:
Yes, I've tried configure with these command line arguments:
./configure -opensource -confirm-license -platform linux-g++ -prefix
/opt/6.1.2-linux-g++-static -static
I got lots of errors after running configure, about missing XCB
libraries, so following the Ubuntu CI script, I installed them with:
apt install "^libxcb.*"
I installed this on Debian 11.
I managed to build a test project with cmake containing this code:
cmake_minimum_required(VERSION 3.20)
project(untitled)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_LINKER ld.gold)
set(CMAKE_PREFIX_PATH "/opt/6.1.2-linux-g++-static/lib/cmake")
find_package(Qt6 COMPONENTS
Core
Gui
Widgets
REQUIRED)
add_executable(untitled main.cpp)
target_link_libraries(untitled
Qt::Core
Qt::Gui
Qt::Widgets
)
Here's the source to main.cpp:
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
QPushButton button("Hello world!", nullptr);
button.resize(200, 100);
button.show();
return QApplication::exec();
}
Afterwards, I used strip on untitled, reducing the size to 16MB. If I
give it to people, I'll provide the object file if they want to relink
it.
If you want to reduce the size of your binary you might consider using
-ltcg (Link time code generation) when building Qt.
See https://www.qt.io/blog/2019/01/02/qt-applications-lto for more
information.
And, for your application have set(CMAKE_INTERPROCEDURAL_OPTIMIZATION
ON) in your CMakeLists.txt file.
You might want to test first with your application, and afterwards with
application and Qt.
The gain should be something like ~15% size decrease, which should get
your application down to 13.6MB
Cheers,
Cristian.
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest