Using libraries in libraries
-
Is it possible to use libraries in libraries?
I added some libraries, both shared and static and got them to work so that I can use them in a desktop application. However, when I try to use a static library in another static library or a shared library in another shared library that does not seem to work.
I get the errorC:\CPP\Test\SharedLib\sharedlib.cpp:4: error: C1083: Cannot open include file: 'sharedlib_2.h': No such file or directory
Is there a way around it? If not, what is the best way to structure projects/libraries. It seems to be very limiting that that libraries cant use other libraries
This is my application's .pro where I can use he library
QT += core QT -= gui CONFIG += c++11 TARGET = Test CONFIG += console CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../SharedLib/release/ -lSharedLib else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../SharedLib/debug/ -lSharedLib INCLUDEPATH += $$PWD/../SharedLib DEPENDPATH += $$PWD/../SharedLib win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../SharedLib_2/release/ -lSharedLib_2 else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../SharedLib_2/debug/ -lSharedLib_2 INCLUDEPATH += $$PWD/../SharedLib_2 DEPENDPATH += $$PWD/../SharedLib_2
and the .pro of SharedLib which is supposed to use SharedLib_2
QT -= gui TARGET = SharedLib TEMPLATE = lib DEFINES += SHAREDLIB_LIBRARY SOURCES += sharedlib.cpp HEADERS += sharedlib.h\ sharedlib_global.h unix { target.path = /usr/lib INSTALLS += target } win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../SharedLib_2/release/ -lSharedLib_2 else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../SharedLib_2/debug/ -lSharedLib_2 INCLUDEPATH += $$PWD/../SharedLib_2 DEPENDPATH += $$PWD/../SharedLib_2
I added them both via the automatic add library and the lines are identically... so I would have expected this to work
includes are
application
#include <QCoreApplication> #include "sharedlib.h" #include "sharedlib_2.h" int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); SharedLib sl; SharedLib_2 sl_2; return a.exec(); }
sharedLib
#include "sharedlib.h" #include "sharedlib_2.h" // ERROR HERE SharedLib::SharedLib() { }
-
Hi,
Not that I want to be picky but you write that you get
error Cannot open include file mylibrary.h: no such file or directory
but in what you provide there's notmylibrary.h
that can be seen. -
Sure it's possible, otherwise how you could any library that has dependencies work ?
Did you re-run qmake after modifying your libs .pro file ?
One thing that is not clear, how are these projects related ? One common with sub-projects or each his own ?
-
Where are they located on your filesystem ?
Where exactly did you build them ?