QT Subdir - неопределенная ссылка - PullRequest
0 голосов
/ 03 декабря 2018

Я работаю над проектом QT с подкаталогами, он прекрасно работает на Linux (Ubuntu), но когда я пытался запустить на Windows, я получаю неопределенную ссылку на `moduleInterface :: ... ´ вкоторый ... относится ко всем методам моего subdir.Версия 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

1 Ответ

0 голосов
/ 03 декабря 2018

Похоже, проблема порядка компиляции.Возможно, компоновщик не может найти некоторые символы, потому что они принадлежат одному из других подпроектов, но они еще не были обработаны.

Попробуйте изменить файл .pro subdirs следующим образом:

TEMPLATE = subdirs

CONFIG += ordered

SUBDIRS += \             
         coreSerialTerm \
         tests \
         serialTermView

Атрибут .depends никогда не работал для меня в Windows.

...