使用 Github 操作为 Windows 编译 QT 应用程序时出错
Error compiling a QT app for Windows with Github Actions
我试图让 Github Actions 在 windows 上编译我的项目,但它失败了。在我的机器上编译时,它编译得很好。为什么它在 Github 个操作上失败?
我也试过使用jurplel/install-qt-action@v2.5.3安装QT,但我得到了同样的错误
该项目可以很好地编译 Mac 和 Linux
编译输出:
Info: creating stash file D:\a\dsda-launcher\dsda-launcher\dsda-launcher\build\.qmake.stash
24
C:/ProgramData/Chocolatey/lib/make/tools/install/bin/make.exe -f Makefile.Release
25
make[1]: Entering directory 'D:/a/dsda-launcher/dsda-launcher/dsda-launcher/build'
26
'C:\Qt.15.2\mingw81_64\bin\uic.exe' ../mainwindow.ui -o ui_mainwindow.h
27
g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DAPP_NAME=dsda-launcher -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I../../dsda-launcher -I. -IC:/Qt/5.15.2/mingw81_64/include -IC:/Qt/5.15.2/mingw81_64/include/QtWidgets -IC:/Qt/5.15.2/mingw81_64/include/QtGui -IC:/Qt/5.15.2/mingw81_64/include/QtANGLE -IC:/Qt/5.15.2/mingw81_64/include/QtNetwork -IC:/Qt/5.15.2/mingw81_64/include/QtConcurrent -IC:/Qt/5.15.2/mingw81_64/include/QtCore -Irelease -I. -I/include -IC:/Qt/5.15.2/mingw81_64/mkspecs/win32-g++ -o release/main.o ../main.cpp
28
g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DAPP_NAME=dsda-launcher -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I../../dsda-launcher -I. -IC:/Qt/5.15.2/mingw81_64/include -IC:/Qt/5.15.2/mingw81_64/include/QtWidgets -IC:/Qt/5.15.2/mingw81_64/include/QtGui -IC:/Qt/5.15.2/mingw81_64/include/QtANGLE -IC:/Qt/5.15.2/mingw81_64/include/QtNetwork -IC:/Qt/5.15.2/mingw81_64/include/QtConcurrent -IC:/Qt/5.15.2/mingw81_64/include/QtCore -Irelease -I. -I/include -IC:/Qt/5.15.2/mingw81_64/mkspecs/win32-g++ -o release/mainwindow.o ../mainwindow.cpp
29
../mainwindow.cpp: In function 'QString lowerCase(std::__cxx11::string)':
30
../mainwindow.cpp:77:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
31
for(int i=0;i<word.length();i++)
32
~^~~~~~~~~~~~~~
33
../mainwindow.cpp: In constructor 'MainWindow::MainWindow(QWidget*)':
34
../mainwindow.cpp:211:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
35
for(int i=0;i<tp.length();i++) // Loop the chars to find the 4 quotes
36
~^~~~~~~~~~~~
37
../mainwindow.cpp:266:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
38
for(int i=0;i<tp.length();i++)
39
~^~~~~~~~~~~~
40
../mainwindow.cpp:308:46: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
41
for(int i=0;i<tp.length();i++)
42
~^~~~~~~~~~~~
43
../mainwindow.cpp: In member function 'void MainWindow::on_LaunchGameButton_clicked(bool, bool)':
44
../mainwindow.cpp:881:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
45
for(int i=0; i<dehFiles.length();i++)
46
~^~~~~~~~~~~~~~~~~~
47
../mainwindow.cpp:893:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
48
for(int i=0; i<files.length();i++)
49
~^~~~~~~~~~~~~~~
50
In file included from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windows.h:65,
51
from ../mainwindow.cpp:1068:
52
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/excpt.h:14:8: error: expected unqualified-id before string constant
53
extern "C" {
54
^~~
55
In file included from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/minwindef.h:6,
56
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windef.h:8,
57
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windows.h:69,
58
from ../mainwindow.cpp:1068:
59
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/specstrings.h:18:8: error: expected unqualified-id before string constant
60
extern "C" {
61
^~~
62
In file included from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windef.h:8,
63
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windows.h:69,
64
from ../mainwindow.cpp:1068:
65
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/minwindef.h:19:8: error: expected unqualified-id before string constant
66
extern "C" {
67
^~~
68
In file included from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/x86intrin.h:27,
69
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/winnt.h:1554,
70
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/minwindef.h:163,
71
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windef.h:8,
72
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windows.h:69,
73
from ../mainwindow.cpp:1068:
74
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ia32intrin.h:55:25: error: expected '}' before end of line
75
#pragma GCC push_options
76
^
77
../mainwindow.cpp:751:1: note: to match this '{'
78
{
79
^
80
In file included from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/x86intrin.h:27,
81
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/winnt.h:1554,
82
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/minwindef.h:163,
83
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windef.h:8,
84
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windows.h:69,
85
from ../mainwindow.cpp:1068:
86
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ia32intrin.h: At global scope:
87
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ia32intrin.h:55:25: error: expected declaration before end of line
88
#pragma GCC push_options
89
^
90
make[1]: *** [Makefile.Release:725: release/mainwindow.o] Error 1
91
make[1]: Leaving directory 'D:/a/dsda-launcher/dsda-launcher/dsda-launcher/build'
92
make: *** [Makefile:45: release] Error 2
Github 操作代码:
steps:
- name: Install qt
run: |
choco install qt5-default
- uses: actions/checkout@v2
- name: build
run: |
C:\Qt.15.2\mingw81_64\bin\qmake.exe ..
make.exe
找到解决方案。在包含任何其他 header 之前,我必须先调用 #include <windows.h>
。我不知道为什么,但它有效。
https://forum.qt.io/topic/38780/solved-errors-with-windows-h
我试图让 Github Actions 在 windows 上编译我的项目,但它失败了。在我的机器上编译时,它编译得很好。为什么它在 Github 个操作上失败?
我也试过使用jurplel/install-qt-action@v2.5.3安装QT,但我得到了同样的错误
该项目可以很好地编译 Mac 和 Linux
编译输出:
Info: creating stash file D:\a\dsda-launcher\dsda-launcher\dsda-launcher\build\.qmake.stash
24
C:/ProgramData/Chocolatey/lib/make/tools/install/bin/make.exe -f Makefile.Release
25
make[1]: Entering directory 'D:/a/dsda-launcher/dsda-launcher/dsda-launcher/build'
26
'C:\Qt.15.2\mingw81_64\bin\uic.exe' ../mainwindow.ui -o ui_mainwindow.h
27
g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DAPP_NAME=dsda-launcher -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I../../dsda-launcher -I. -IC:/Qt/5.15.2/mingw81_64/include -IC:/Qt/5.15.2/mingw81_64/include/QtWidgets -IC:/Qt/5.15.2/mingw81_64/include/QtGui -IC:/Qt/5.15.2/mingw81_64/include/QtANGLE -IC:/Qt/5.15.2/mingw81_64/include/QtNetwork -IC:/Qt/5.15.2/mingw81_64/include/QtConcurrent -IC:/Qt/5.15.2/mingw81_64/include/QtCore -Irelease -I. -I/include -IC:/Qt/5.15.2/mingw81_64/mkspecs/win32-g++ -o release/main.o ../main.cpp
28
g++ -c -fno-keep-inline-dllexport -O2 -std=gnu++11 -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DAPP_NAME=dsda-launcher -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I../../dsda-launcher -I. -IC:/Qt/5.15.2/mingw81_64/include -IC:/Qt/5.15.2/mingw81_64/include/QtWidgets -IC:/Qt/5.15.2/mingw81_64/include/QtGui -IC:/Qt/5.15.2/mingw81_64/include/QtANGLE -IC:/Qt/5.15.2/mingw81_64/include/QtNetwork -IC:/Qt/5.15.2/mingw81_64/include/QtConcurrent -IC:/Qt/5.15.2/mingw81_64/include/QtCore -Irelease -I. -I/include -IC:/Qt/5.15.2/mingw81_64/mkspecs/win32-g++ -o release/mainwindow.o ../mainwindow.cpp
29
../mainwindow.cpp: In function 'QString lowerCase(std::__cxx11::string)':
30
../mainwindow.cpp:77:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
31
for(int i=0;i<word.length();i++)
32
~^~~~~~~~~~~~~~
33
../mainwindow.cpp: In constructor 'MainWindow::MainWindow(QWidget*)':
34
../mainwindow.cpp:211:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
35
for(int i=0;i<tp.length();i++) // Loop the chars to find the 4 quotes
36
~^~~~~~~~~~~~
37
../mainwindow.cpp:266:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
38
for(int i=0;i<tp.length();i++)
39
~^~~~~~~~~~~~
40
../mainwindow.cpp:308:46: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
41
for(int i=0;i<tp.length();i++)
42
~^~~~~~~~~~~~
43
../mainwindow.cpp: In member function 'void MainWindow::on_LaunchGameButton_clicked(bool, bool)':
44
../mainwindow.cpp:881:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
45
for(int i=0; i<dehFiles.length();i++)
46
~^~~~~~~~~~~~~~~~~~
47
../mainwindow.cpp:893:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
48
for(int i=0; i<files.length();i++)
49
~^~~~~~~~~~~~~~~
50
In file included from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windows.h:65,
51
from ../mainwindow.cpp:1068:
52
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/excpt.h:14:8: error: expected unqualified-id before string constant
53
extern "C" {
54
^~~
55
In file included from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/minwindef.h:6,
56
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windef.h:8,
57
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windows.h:69,
58
from ../mainwindow.cpp:1068:
59
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/specstrings.h:18:8: error: expected unqualified-id before string constant
60
extern "C" {
61
^~~
62
In file included from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windef.h:8,
63
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windows.h:69,
64
from ../mainwindow.cpp:1068:
65
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/minwindef.h:19:8: error: expected unqualified-id before string constant
66
extern "C" {
67
^~~
68
In file included from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/x86intrin.h:27,
69
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/winnt.h:1554,
70
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/minwindef.h:163,
71
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windef.h:8,
72
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windows.h:69,
73
from ../mainwindow.cpp:1068:
74
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ia32intrin.h:55:25: error: expected '}' before end of line
75
#pragma GCC push_options
76
^
77
../mainwindow.cpp:751:1: note: to match this '{'
78
{
79
^
80
In file included from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/x86intrin.h:27,
81
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/winnt.h:1554,
82
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/minwindef.h:163,
83
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windef.h:8,
84
from C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windows.h:69,
85
from ../mainwindow.cpp:1068:
86
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ia32intrin.h: At global scope:
87
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/ia32intrin.h:55:25: error: expected declaration before end of line
88
#pragma GCC push_options
89
^
90
make[1]: *** [Makefile.Release:725: release/mainwindow.o] Error 1
91
make[1]: Leaving directory 'D:/a/dsda-launcher/dsda-launcher/dsda-launcher/build'
92
make: *** [Makefile:45: release] Error 2
Github 操作代码:
steps:
- name: Install qt
run: |
choco install qt5-default
- uses: actions/checkout@v2
- name: build
run: |
C:\Qt.15.2\mingw81_64\bin\qmake.exe ..
make.exe
找到解决方案。在包含任何其他 header 之前,我必须先调用 #include <windows.h>
。我不知道为什么,但它有效。
https://forum.qt.io/topic/38780/solved-errors-with-windows-h