QT创建者使用静态库

时间:2016-10-01 11:28:25

标签: c++ qt

我正在尝试按照qt创建者的说明创建静态库。 https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application

它显示了我的库中包含的行.pro

TEMPLATE = lib
CONFIG += staticlib

# Input
HEADERS += test.h
SOURCES += test.cpp

和应用.pro

TEMPLATE = app
TARGET =
CONFIG += console

# Input
SOURCES += main.cpp
INCLUDEPATH += ../staticLibrary
LIBS += -L../staticLibrary/debug -lstaticLibrary

我有

library' s .pro

QT       -= gui

TARGET = test
TEMPLATE = lib
CONFIG += staticlib

SOURCES += test.cpp

HEADERS += test.h
unix {
    target.path = /usr/lib
    INSTALLS += target
}

app的.pro

QT += core
QT -= gui

CONFIG += c++11

TARGET = TestLink
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

SOURCES += main.cpp


INCLUDEPATH += ../test  // ADDED BY ME
LIBS += -L../test/debug -ltest  //ADDED BY ME
// LIBS += -L../test/debug -ltest.a  //ALSO TRIED .a

我的图书馆正在测试中。文件夹,主应用程序和库都在同一个文件夹中。当我现在包括.h

#include "test.h"

我得到了

C:\CPP\Test\TestLink\main.cpp:3: error: C1083: Cannot open include file: 'test.h': No such file or directory

似乎我在这里遵循isntructions。我错过了什么?

这也表明我添加的两行应该完成这项工作 Using a static library in Qt Creator

0 个答案:

没有答案