windows: add extra link libraries for static qwindows plugin

This commit is contained in:
mappu 2024-09-03 20:11:23 +12:00
parent ca2e3c4a19
commit cef75b87bd
3 changed files with 24 additions and 1 deletions

View File

@ -76,6 +76,6 @@ Some C++ idioms that were difficult to project were omitted from the binding. Bu
1. Build the necessary docker container for cross-compilation:
- `docker build -t miqt/win64-cross:latest -f win64-cross-go1.23-qt5.15-static.Dockerfile .`
2. Build your application:
- `docker run --rm -v $(pwd):/src -w /src miqt/win64-cross:latest go build -buildvcs=false -ldflags '-s -w -H windowsgui'`
- `docker run --rm -v $(pwd):/src -w /src miqt/win64-cross:latest go build -buildvcs=false --tags=windowsqtstatic -ldflags '-s -w -H windowsgui'`
For repeated builds, the compile speed can be improved if you also bind-mount the Docker container's `GOCACHE` directory: `-v $(pwd)/container-build-cache:/root/.cache/go-build`

View File

@ -0,0 +1,6 @@
#ifdef MIQT_WINDOWSQTSTATIC
#include <QtPlugin>
Q_IMPORT_PLUGIN (QWindowsIntegrationPlugin);
#endif

View File

@ -0,0 +1,17 @@
//go:build windowsqtstatic
// +build windowsqtstatic
package qt
// Some extra libraries should be linked to make a proper static build.
// Otherwise, it can cause "No Qt platform plugin could be initialized" error.
// @ref https://github.com/mappu/miqt/issues/25
// @ref https://stackoverflow.com/a/16776116
// @ref https://stackoverflow.com/a/58648193
// @ref https://stackoverflow.com/a/57374635
/*
#cgo windowsqtstatic CXXFLAGS: -DMIQT_WINDOWSQTSTATIC
#cgo LDFLAGS: -L/usr/lib/mxe/usr/x86_64-w64-mingw32.static/qt5/plugins/platforms -lqwindows -lQt5FontDatabaseSupport -lQt5EventDispatcherSupport -lQt5ThemeSupport -lQt5PlatformCompositorSupport -lQt5AccessibilitySupport -lQt5WindowsUIAutomationSupport -lwtsapi32
*/
import "C"