PDA

View Full Version : how to create application with 2 library



stevocz
26th August 2013, 12:28
hi.

i create application where i use 2 library.
library1 is used in library2 and library2 is used in application.

library1 and library2 is compiled OK, but when i try compile App, i have error:

No such file or directory xxx.h, but this xxx.h is in library1

how can i load this library in app?

.pro file of library1

TARGET = library1
TEMPLATE = lib
CONFIG += staticlib
QT += network
DEFINES += QLIBRARY1_LIBRARY
MOC_DIR = tmp
OBJECTS_DIR = obj
DESTDIR += ../libLibrary1/bin

.pro file of library2

QT += core gui sql network
TARGET = library2
TEMPLATE = lib
CONFIG += staticlib
DEFINES += QLIBRARY2_LIBRARY
DESTDIR = ../libLibrary2
MOC_DIR = tmp
OBJECTS_DIR = obj
INCLUDEPATH += ../libLibrary1
QMAKE_LIBDIR += ../libLibrary1
LIBS += -L/bin -llibrary1

.pro file of app

QT += core gui
TARGET = QApp
TEMPLATE = app
INCLUDEPATH += ../libLibrary2
QMAKE_LIBDIR += ../libLibrary2
LIBS += -llibrary2

Santosh Reddy
26th August 2013, 12:36
No such file or directory xxx.h, but this xxx.h is in library1
May be you are including xxx.h file from a header file of library2 which is being included from app.

Options:
1. Add library1 include path in app project file
2. Change the library2 header files (which are needed by app) so that they don't depen of xxx.h file

stevocz
26th August 2013, 12:51
all .h files from library1 have same error.

app is for now only mainwindow for test. In library2 is widget and this widget want i show in app

ChrisW67
26th August 2013, 21:10
all .h files from library1 have same error.
So the same solution will fix all of them.
The compiler needs to know how to find all the include files the application needs in order to compile it. If the application needs the definition of a class in lib A to compile then it will need ( directly or indirectly) access to a header that defines it. You can adjust the places the compiler looks with INCLUDEPATH.