尝试链接到外部静态库。但是QT创建者正在编译外部库源文件

问题描述 投票:0回答:1

这一切在带有QT创建者4.5.2的Ubuntu 18.04上发生。该项目是QT小部件项目。我想链接到在netbeans中创建的静态链接的C ++库。但是当我建造时QT Creator不仅链接到静态库,它还会编译库(game.cpp)中的文件并生成以下错误。

/ home / bobp040653 / Scrabble / Programming / ScrabbleLib / Game.cpp:9:错误:对`ScrabbleLib :: Game :: TileBag :: tileValues'的未定义引用

我一点都不明白。 Game.o是外部静态链接库的一部分。它在netbeans下可以正常编译。是因为该库是libscrabblelib.a吗?这是QT无法识别的库类型吗?

这是我的项目的.pro文件的副本。

#-------------------------------------------------
#
# Project created by QtCreator 2020-03-03T10:32:12
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = TipTopQTW
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


SOURCES += \
        main.cpp \
        tiptop.cpp

HEADERS += \
        tiptop.h

FORMS += \
        tiptop.ui

unix:!macx: LIBS += -L$$PWD/../ScrabbleLib/dist/Debug/GNU-Linux/ -lscrabblelib

INCLUDEPATH += $$PWD/../ScrabbleLib
DEPENDPATH += $$PWD/../ScrabbleLib

unix:!macx: PRE_TARGETDEPS += $$PWD/../ScrabbleLib/dist/Debug/GNU-Linux/libscrabblelib.a
c++ qt-creator static-libraries
1个回答
0
投票

您添加了DEPENDPATH += $$PWD/../ScrabbleLib,它告诉Qt编译文件。

© www.soinside.com 2019 - 2024. All rights reserved.