无法在Qt“未定义的引用..”错误中将我的静态库添加到我的应用中

时间:2018-09-07 12:09:13

标签: qt static-libraries

我的应用的专业文件

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = ReceiverTest
TEMPLATE = app

INCLUDEPATH += "C:/Users/test/Desktop/QtProjects/UdpReceiver"
LIBS += "C:/Users/test/Desktop/QtProjects/build-UdpReceiver-Desktop_Qt_5_9_1_MinGW_32bit-Release/release/libUdpReceiver.a"

SOURCES += \
        main.cpp \
        mainwindow.cpp

HEADERS += \
        mainwindow.h \
    ../UdpReceiver/udpreceiver.h

FORMS += \
        mainwindow.ui

哪个给出了“未定义的引用”,并添加了以下行:“找不到文件:updreceiver.cpp”

UdpReceiver是我使用Qt Creator创建的库。

使用Qt创建者自己的“添加库”选项会导致将这段代码添加到makefile中。

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../build-UdpReceiver-Desktop_Qt_5_9_1_MinGW_32bit-Release/release/ -lUdpReceiver
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../build-UdpReceiver-Desktop_Qt_5_9_1_MinGW_32bit-Release/debug/ -lUdpReceiver
else:unix: LIBS += -L$$PWD/../build-UdpReceiver-Desktop_Qt_5_9_1_MinGW_32bit-Release/ -lUdpReceiver

INCLUDEPATH += $$PWD/../build-UdpReceiver-Desktop_Qt_5_9_1_MinGW_32bit-Release/release
DEPENDPATH += $$PWD/../build-UdpReceiver-Desktop_Qt_5_9_1_MinGW_32bit-Release/release

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../build-UdpReceiver-Desktop_Qt_5_9_1_MinGW_32bit-Release/release/libUdpReceiver.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../build-UdpReceiver-Desktop_Qt_5_9_1_MinGW_32bit-Release/debug/libUdpReceiver.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../build-UdpReceiver-Desktop_Qt_5_9_1_MinGW_32bit-Release/release/UdpReceiver.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../build-UdpReceiver-Desktop_Qt_5_9_1_MinGW_32bit-Release/debug/UdpReceiver.lib
else:unix: PRE_TARGETDEPS += $$PWD/../build-UdpReceiver-Desktop_Qt_5_9_1_MinGW_32bit-Release/libUdpReceiver.a

哪个给:

 ":-1: error: No rule to make target 'C:/Users/test/Desktop/QtProjects/ReceiverTest/../build-UdpReceiver-Desktop_Qt_5_9_1_MinGW_32bit-Release/debug/libUdpReceiver.a', needed by 'debug\ReceiverTest.exe'.  Stop." error.

0 个答案:

没有答案