提问人:lightshadown 提问时间:5/4/2020 最后编辑:Jason Allerlightshadown 更新时间:9/17/2020 访问量:542
链接器错误,不会在 Windows 上编译,但在 Mac、Qt 上编译,但所有库都已链接且正常
linker error, wont compile on Windows but compiles on Mac, Qt but all the libraries are already linked and fine
问:
我正在尝试编译我的程序,它已经在另一台机器(Mac)上运行,我只是将其复制到一台新机器(Windows),因为客户端希望它用于 Windows 10,现在它根本无法识别我所有的 qtwidgets,它是否找到正确的库并不重要。
我已经检查了库(qtCore、QtSql 等),它们很好且已链接,但仍然收到警告“未定义对对象的引用”,我将粘贴我从输出窗口中获得的内容。
我在 Windows 上使用 netbeans Qt 5.12.8,该程序是在 mac Qt 5.11.3 上制作的
我使用 Mkspace win32-g++ 安装了 MinGW g++,它是唯一似乎可以工作的 mk 空间,但不能更进一步,我已经尝试了不同的 Qmakes 和 mkspaces,但它只会变得更糟。
程序
pantalla_principal.cpp --> https://pastebin.com/jSzwT42s
pantalla_principal.h ---> https://pastebin.com/qH2F4XaG
Login.cpp ---> https://pastebin.com/JDXcrYYe
Login.h ---> https://pastebin.com/e5PsDM5g
ui_Login.h --> https://pastebin.com/7SqX62Pt
ui_Pantalla_Principal.h --> https://pastebin.com/vNByjKgG
输出窗口
cd 'C:\Users\Patron\Desktop\Code Projects\Sistema_Silo'
C:\make-3.81-bin\bin\make.exe -f Makefile CONF=Debug QMAKE=/C/Qt/Qt5.12.8/5.12.8/msvc2015_64/bin/qmake.exe
"/C/make-3.81-bin/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE=/C/Qt/Qt5.12.8/5.12.8/msvc2015_64/bin/qmake.exe SUBPROJECTS= .build-conf
make[1]: se ingresa al directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
c:/Qt/Qt5.12.8/5.12.8/msvc2015_64/bin/qmake.exe VPATH=. -spec win32-g++ -o qttmp-Debug.mk nbproject/qt-Debug.pro
mv -f qttmp-Debug.mk nbproject/qt-Debug.mk
"c:/make-3.81-bin/bin/make.exe" -f nbproject/qt-Debug.mk dist/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Sistema_Silo.exe
make[2]: se ingresa al directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
g++ -c -fno-keep-inline-dllexport -g -Wall -W -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_SQL_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -Inbproject -I. -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtWidgets -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtGui -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtANGLE -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtSql -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtCore -I. -I. -I/include -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/mkspecs/win32-g++ -o build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Login.o Login.cpp
In file included from C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtCore/QVariant:1,
from ui_Login.h:12,
from Login.h:17,
from Login.cpp:14:
C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtCore/qvariant.h: In constructor 'QVariant::QVariant(QVariant&&)':
C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtCore/qvariant.h:273:25: warning: implicitly-declared 'constexpr QVariant::Private& QVariant::Private::operator=(const QVariant::Private&)' is deprecated [-Wdeprecated-copy]
273 | { other.d = Private(); }
| ^
C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtCore/qvariant.h:399:16: note: because 'QVariant::Private' has user-provided 'QVariant::Private::Private(const QVariant::Private&)'
399 | inline Private(const Private &other) Q_DECL_NOTHROW
| ^~~~~~~
windres -i Sistema_Silo_resource.rc -o build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Sistema_Silo_resource_res.o --include-dir=. -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_SQL_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN
g++ -Wl,-subsystem,windows -mthreads -o dist/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Sistema_Silo.exe build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Login.o build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Pantalla_Principal.o build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/main_Pantalla_Principal.o build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/moc_Login.o build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/moc_Pantalla_Principal.o C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/lib/libQt5Widgetsd.a
C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/lib/libQt5Guid.a C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/lib/libQt5Sqld.a C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/lib/libQt5Cored.a build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Sistema_Silo_resource_res.o -lmingw32 C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/lib/libqtmaind.a
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Login.o: in function `ZN9EmbarquesC2Ev':
C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Login.cpp:20: undefined reference to `_imp___ZN7QWidgetC2EPS_6QFlagsIN2Qt10WindowTypeEE'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Login.cpp:22: undefined reference to `_imp___Z13qFlagLocationPKc'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Login.cpp:22: undefined reference to `_imp___Z13qFlagLocationPKc'
...
这对于我所有的 qtwidget 来说一直在进行,所以我不得不修剪它,但这基本上是相同的警告
...
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Login.o: in function `ZN9Embarques8AprovadoEv':
C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtCore/qarraydata.h:239: undefined reference to `_imp___ZN10QArrayData10deallocateEPS_jj'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Pantalla_Principal.o: in function `ZN18Pantalla_PrincipalC2Ev':
C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Pantalla_Principal.cpp:31: undefined reference to `_imp___ZN11QMainWindowC2EP7QWidget6QFlagsIN2Qt10WindowTypeEE'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/ui_Pantalla_Principal.h:353: undefined reference to `_imp___ZN8QPalette8setBrushENS_10ColorGroupENS_9ColorRoleERK6QBrush'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/moc_Login.o:moc_Login.cpp:(.rdata$_ZTV9Embarques[__ZTV9Embarques]+0x70): undefined reference to `QWidget::focusInEvent(QFocusEvent*)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(main.o):(.text.startup+0xc0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [dist/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Sistema_Silo.exe] Error 1
make[2]: se sale del directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
make[1]: *** [.build-conf] Error 2
make[1]: se sale del directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 26s)
这是这个程序的制作文件,它有点大,所以我使用了粘贴箱,希望它能工作: https://pastebin.com/Jg9Jz69h
编辑 1:我制作了自己的自定义 Mkfile,以便准确地指向 mingw32-g++ 编译器,我将其设置为 mkspace,但我仍然收到相同的警告。
这是我的输出,我不得不修剪它,但它都是一样的:
cd 'C:\Users\Patron\Desktop\Code Projects\Sistema_Silo'
C:\make-3.81-bin\bin\make.exe -f Makefile CONF=Debug QMAKE=/C/Qt/Qt5.12.8/5.12.8/mingw73_64/bin/qmake.exe
"/C/make-3.81-bin/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE=/C/Qt/Qt5.12.8/5.12.8/mingw73_64/bin/qmake.exe SUBPROJECTS= .build-conf
make[1]: se ingresa al directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
c:/Qt/Qt5.12.8/5.12.8/mingw73_64/bin/qmake.exe VPATH=. -spec win32-g++-mingw32 -o qttmp-Debug.mk nbproject/qt-Debug.pro
mv -f qttmp-Debug.mk nbproject/qt-Debug.mk
"c:/make-3.81-bin/bin/make.exe" -f nbproject/qt-Debug.mk dist/Debug/MinGW-Windows/Sistema_Silo.exe
make[2]: se ingresa al directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
mingw32-g++ -Wl,-subsystem,windows -mthreads -o dist/Debug/MinGW-Windows/Sistema_Silo.exe build/Debug/MinGW-Windows/Login.o build/Debug/MinGW-Windows/Pantalla_Principal.o build/Debug/MinGW-Windows/main_Pantalla_Principal.o build/Debug/MinGW-Windows/moc_Login.o build/Debug/MinGW-Windows/moc_Pantalla_Principal.o C:/Qt/Qt5.12.8/5.12.8/mingw73_64/lib/libQt5Widgetsd.a C:/Qt/Qt5.12.8/5.12.8/mingw73_64/lib/libQt5Guid.a C:/Qt/Qt5.12.8/5.12.8/mingw73_64/lib/libQt5Sqld.a C:/Qt/Qt5.12.8/5.12.8/mingw73_64/lib/libQt5Cored.a build/Debug/MinGW-Windows/Sistema_Silo_resource_res.o -lmingw32 C:/Qt/Qt5.12.8/5.12.8/mingw73_64/lib/libqtmaind.a -LC:/openssl/lib -LC:/Utils/my_sql/mysql-5.6.11-winx64/lib -LC:/Utils/postgresql/pgsql/lib -lshell32
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/MinGW-Windows/Login.o: in function `ZN9EmbarquesC2Ev':
C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Login.cpp:20: undefined reference to `_imp___ZN7QWidgetC2EPS_6QFlagsIN2Qt10WindowTypeEE'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Login.cpp:22: undefined reference to `_imp___Z13qFlagLocationPKc'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Login.cpp:22: undefined reference to `_imp___Z13qFlagLocationPKc'
....
....
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/MinGW-Windows/moc_Pantalla_Principal.o:moc_Pantalla_Principal.cpp:(.rdata$_ZTV18Pantalla_Principal[__ZTV18Pantalla_Principal]+0xf4): undefined reference to `non-virtual thunk to QWidget::metric(QPaintDevice::PaintDeviceMetric) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/MinGW-Windows/moc_Pantalla_Principal.o:moc_Pantalla_Principal.cpp:(.rdata$_ZTV18Pantalla_Principal[__ZTV18Pantalla_Principal]+0xf8): undefined reference to `non-virtual thunk to QWidget::initPainter(QPainter*) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/MinGW-Windows/moc_Pantalla_Principal.o:moc_Pantalla_Principal.cpp:(.rdata$_ZTV18Pantalla_Principal[__ZTV18Pantalla_Principal]+0xfc): undefined reference to `non-virtual thunk to QWidget::redirected(QPoint*) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/MinGW-Windows/moc_Pantalla_Principal.o:moc_Pantalla_Principal.cpp:(.rdata$_ZTV18Pantalla_Principal[__ZTV18Pantalla_Principal]+0x100): undefined reference to `non-virtual thunk to QWidget::sharedPainter() const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(main.o):(.text.startup+0xc0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/Sistema_Silo.exe] Error 1
make[2]: se sale del directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
make[1]: *** [.build-conf] Error 2
make[1]: se sale del directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 6s)
编辑 2:
我正在使用 Msys 的 make 命令似乎效果更好一些,我仍然收到未定义的引用错误,但至少没有指向 qt 文件中的错误,无论如何它都是链接器错误。
https://pastebin.com/ZDnCF8zn mkfile
https://pastebin.com/WA34zcrT mingw32-g++ 的新 makefile
编辑 3: 我从字面上使用了计算机中安装的每个编译器,从 g++ 到 mingw g++ 和 qt g++,还使用了 qt 附带的 makes,一无所获。还安装了Qt 5.8,以防万一旧版本可以解决问题,什么都没有。
我需要选择,我真的没有想法了,我什至创建了一个全新的项目以防万一,但没有奏效。
编辑 4: 我安装了 QT 5.11.3,并使用了 Mingw 5.3 32 位构建,它以某种方式设法部分编译,让我解释一下,我的问题是它没有编译或创建根本没有 .exe 文件,通过使用 Qmake qt 5.11.3 它设法编译但它有几个错误
缺少 .dll 文件,我不得不手动将其(QT5Guid.dll、QT5Core.dll 等)复制到构建文件夹,没什么大不了的
编译时,我从文件 qstyleoption.h 中收到基本上每个函数的错误,就像这样
粘贴盒 --> https://pastebin.com/9rzXR69i
我确实得到了一个.exe文件,但每次我尝试运行它时,我都会收到警告应用程序无法正确启动0xc00007b,按确定继续,根据 Google 的说法,这是Microsoft可再发行 c++ 的问题(我重新安装并获得了 2015-2019 x64 和 x86 版本)
所以这基本上是部分胜利
答: 暂无答案
评论