繁体   English   中英

试图链接到外部静态库。 但是QT creator正在编译外部库源文件

[英]Trying to link to an external static library. But QT creator is compiling the external library source files

这一切都发生在 Ubuntu 18.04 上,QT Creator 4.5.2。 该项目是一个 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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM