QT 子目录 - 未定义的参考
QT Subdir - Undefined Reference
我正在开发一个带有子目录的 QT 项目,它在 linux (ubuntu) 上工作得很好但是当我尝试在 windows 上 运行 我得到对 `moduleInterface::...´ 的未定义引用,其中 ... 指的是我的子目录中的所有方法。我使用的 Qt 版本 (5.11.2) 在 linux 和 windows 中是相同的。子目录配置如下:
main.pro
TEMPLATE = subdirs
SUBDIRS += \
tests \
coreSerialTerm \
serialTermView
serialTermView.depends = coreSerialTerm
tests.depends = coreSerialTerm
coreSerialTerm.pro
QT -= gui
QT += serialport
QT += core
CONFIG += c++14
TARGET = coreSerialTerm
TEMPLATE = lib
DEFINES += CORESERIALTERM_LIBRARY
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
coreserialterm.cpp \
serialInterface/serialinterface.cpp \
moduleInterface/moduleinterface.cpp \
serialProtocol/serialProtocol.c \
moduleInterface/progressbar.cpp \
agroflashinterface.cpp \
Storage/event_list.c \
Storage/storage.c \
flashfilehandler.cpp
HEADERS += \
coreserialterm.h \
coreserialterm_global.h \
serialInterface/serialinterface.h \
moduleInterface/moduleinterface.h \
serialProtocol/serialProtocol.h \
devRetCode.h \
moduleInterface/progressbar.h \
Sensors/sensor.h \
Storage/storage.h \
Utils/configManager.h \
Utils/configStates.h \
Utils/delayPlus.h \
Utils/io.h \
Utils/rtcManager.h \
Utils/wdg.h \
version.h \
module.h \
flashfilehandler.h
serialTermView.pro
QT += core gui
QT += serialport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = serialTermView
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../coreSerialTerm/release/ -lcoreSerialTerm
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../coreSerialTerm/debug/ -lcoreSerialTerm
else:unix: LIBS += -L$$OUT_PWD/../coreSerialTerm/ -lcoreSerialTerm
INCLUDEPATH += $$PWD/../coreSerialTerm
DEPENDPATH += $$PWD/../coreSerialTerm
编译时,出现以下错误:
debug/mainwindow.o: In function `ZN10MainWindowC2EP7QWidget':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:13: undefined reference to `flashFileHandler::flashFileHandler()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:18: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:18: undefined reference to `moduleInterface::availablePorts()'
debug/mainwindow.o: In function `operator()':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:58: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:58: undefined reference to `moduleInterface::connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:65: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:65: undefined reference to `moduleInterface::close()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:106: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:106: undefined reference to `moduleInterface::getTime(unsigned int*)'
debug/mainwindow.o: In function `ZN10MainWindow7getTimeEv':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:98: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:98: undefined reference to `moduleInterface::isConnected()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:138: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:138: undefined reference to `moduleInterface::close()'
debug/mainwindow.o: In function `operator()':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:163: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:163: undefined reference to `moduleInterface::setTime()'
debug/mainwindow.o: In function `ZN10MainWindow7setTimeEv':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:148: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:148: undefined reference to `moduleInterface::isConnected()'
debug/mainwindow.o: In function `operator()':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:229: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:229: undefined reference to `moduleInterface::memoryDump(unsigned char*, unsigned int)'
debug/mainwindow.o: In function `ZN10MainWindow7memDumpEv':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:210: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:210: undefined reference to `moduleInterface::isConnected()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:226: undefined reference to `moduleInterface::pageChanged(int)'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:223: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:261: undefined reference to `moduleInterface::Instance()'
debug/mainwindow.o: In function `ZN10MainWindow6saveAsEv':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:279: undefined reference to `flashFileHandler::open(QString)'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:281: undefined reference to `flashFileHandler::save(QString)'
debug/mainwindow.o: In function `ZN10MainWindow4saveEv':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:288: undefined reference to `flashFileHandler::isReady()'
debug/mainwindow.o: In function `ZN10MainWindow9closePortEv':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:297: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:297: undefined reference to `moduleInterface::close()'
debug/mainwindow.o: In function `connect<void (moduleInterface::*)(int), MainWindow::memDump()::<lambda(int)> >':
C:/Qt/5.11.2/mingw53_32/include/QtCore/qobject.h:333: undefined reference to `moduleInterface::staticMetaObject'
collect2.exe: error: ld returned 1 exit status
好像是编译顺序问题。可能链接器找不到某些符号,因为它们属于其他子项目之一,但尚未处理。
尝试按如下方式更改您的子目录 .pro 文件:
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += \
coreSerialTerm \
tests \
serialTermView
.depends 属性在 windows 上从未对我真正起作用。
我正在开发一个带有子目录的 QT 项目,它在 linux (ubuntu) 上工作得很好但是当我尝试在 windows 上 运行 我得到对 `moduleInterface::...´ 的未定义引用,其中 ... 指的是我的子目录中的所有方法。我使用的 Qt 版本 (5.11.2) 在 linux 和 windows 中是相同的。子目录配置如下:
main.pro
TEMPLATE = subdirs
SUBDIRS += \
tests \
coreSerialTerm \
serialTermView
serialTermView.depends = coreSerialTerm
tests.depends = coreSerialTerm
coreSerialTerm.pro
QT -= gui
QT += serialport
QT += core
CONFIG += c++14
TARGET = coreSerialTerm
TEMPLATE = lib
DEFINES += CORESERIALTERM_LIBRARY
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
coreserialterm.cpp \
serialInterface/serialinterface.cpp \
moduleInterface/moduleinterface.cpp \
serialProtocol/serialProtocol.c \
moduleInterface/progressbar.cpp \
agroflashinterface.cpp \
Storage/event_list.c \
Storage/storage.c \
flashfilehandler.cpp
HEADERS += \
coreserialterm.h \
coreserialterm_global.h \
serialInterface/serialinterface.h \
moduleInterface/moduleinterface.h \
serialProtocol/serialProtocol.h \
devRetCode.h \
moduleInterface/progressbar.h \
Sensors/sensor.h \
Storage/storage.h \
Utils/configManager.h \
Utils/configStates.h \
Utils/delayPlus.h \
Utils/io.h \
Utils/rtcManager.h \
Utils/wdg.h \
version.h \
module.h \
flashfilehandler.h
serialTermView.pro
QT += core gui
QT += serialport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = serialTermView
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../coreSerialTerm/release/ -lcoreSerialTerm
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../coreSerialTerm/debug/ -lcoreSerialTerm
else:unix: LIBS += -L$$OUT_PWD/../coreSerialTerm/ -lcoreSerialTerm
INCLUDEPATH += $$PWD/../coreSerialTerm
DEPENDPATH += $$PWD/../coreSerialTerm
编译时,出现以下错误:
debug/mainwindow.o: In function `ZN10MainWindowC2EP7QWidget':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:13: undefined reference to `flashFileHandler::flashFileHandler()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:18: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:18: undefined reference to `moduleInterface::availablePorts()'
debug/mainwindow.o: In function `operator()':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:58: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:58: undefined reference to `moduleInterface::connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:65: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:65: undefined reference to `moduleInterface::close()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:106: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:106: undefined reference to `moduleInterface::getTime(unsigned int*)'
debug/mainwindow.o: In function `ZN10MainWindow7getTimeEv':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:98: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:98: undefined reference to `moduleInterface::isConnected()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:138: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:138: undefined reference to `moduleInterface::close()'
debug/mainwindow.o: In function `operator()':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:163: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:163: undefined reference to `moduleInterface::setTime()'
debug/mainwindow.o: In function `ZN10MainWindow7setTimeEv':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:148: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:148: undefined reference to `moduleInterface::isConnected()'
debug/mainwindow.o: In function `operator()':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:229: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:229: undefined reference to `moduleInterface::memoryDump(unsigned char*, unsigned int)'
debug/mainwindow.o: In function `ZN10MainWindow7memDumpEv':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:210: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:210: undefined reference to `moduleInterface::isConnected()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:226: undefined reference to `moduleInterface::pageChanged(int)'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:223: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:261: undefined reference to `moduleInterface::Instance()'
debug/mainwindow.o: In function `ZN10MainWindow6saveAsEv':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:279: undefined reference to `flashFileHandler::open(QString)'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:281: undefined reference to `flashFileHandler::save(QString)'
debug/mainwindow.o: In function `ZN10MainWindow4saveEv':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:288: undefined reference to `flashFileHandler::isReady()'
debug/mainwindow.o: In function `ZN10MainWindow9closePortEv':
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:297: undefined reference to `moduleInterface::Instance()'
C:\Users\Augusto\Documents\Workspace\serialTerm\build-serialTerm-Desktop_Qt_5_11_2_MinGW_32bit-Debug\serialTermView/../../serialTerm/serialTermView/mainwindow.cpp:297: undefined reference to `moduleInterface::close()'
debug/mainwindow.o: In function `connect<void (moduleInterface::*)(int), MainWindow::memDump()::<lambda(int)> >':
C:/Qt/5.11.2/mingw53_32/include/QtCore/qobject.h:333: undefined reference to `moduleInterface::staticMetaObject'
collect2.exe: error: ld returned 1 exit status
好像是编译顺序问题。可能链接器找不到某些符号,因为它们属于其他子项目之一,但尚未处理。
尝试按如下方式更改您的子目录 .pro 文件:
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += \
coreSerialTerm \
tests \
serialTermView
.depends 属性在 windows 上从未对我真正起作用。