1

I am trying to follow qt creators instructions to create static libraries. https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application

it shows the below for lines to include in my libraries .pro

TEMPLATE = lib
CONFIG += staticlib

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

and for the apps .pro

TEMPLATE = app
TARGET =
CONFIG += console

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

I have

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's .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

My library is test. Both folder, the main app and the library are in the same folder. When I now include the .h

#include "test.h"

I get

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

It seems I am following the isntructions here. What am I missing?

This here also suggests the two lines I added should do the job Using a static library in Qt Creator

Community
  • 1
  • 1
chrise
  • 4,039
  • 3
  • 39
  • 74
  • `Cannot open include file: 'test.h'` is a compiler error, while `LIBS+=` is a linker flag. I think you need INCLUDEPATH - see https://stackoverflow.com/questions/19048098/includepath-in-qmake-project-file-doesnt-work. – sashoalm Oct 01 '16 at 12:01
  • I tried this INCLUDEPATH += C:\\CPP\\Test\\test but it also doesn't work I see now the error changed to :-1: error: LNK1104: cannot open file 'test.lib' – chrise Oct 01 '16 at 12:09
  • and I do not see a test.lib file anywhere in that folder. There is an object file library in C:\CPP\Test\build-test-Desktop_Qt_5_7_0_MSVC2015_64bit-Debug\debug But including that path also does not help. Is that the file I am looking for? – chrise Oct 01 '16 at 12:12

0 Answers0