PDA

View Full Version : How to link one application to another



kamlmish
24th December 2010, 04:17
Hi
I have a very trivial issue where I have two application (GALLERY) and (ADDFOLDER)
and I need to make GALLERY dependent on ADDFOLDER.

The pro file for GALLERY



QT += core gui

TARGET = GALLERY
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp \
settingstree.cpp \
displayframe.cpp \
PREVIEWFRAME.cpp \
PanelFrame.cpp \
eBeamTree.cpp \
MainFrame.cpp

HEADERS += mainwindow.h \
settingstree.h \
displayframe.h \
PREVIEWFRAME.h \
PanelFrame.h \
eBeamTree.h \
MainFrame.h

RESOURCES += \
GALL.qrc






QT += core gui

TARGET = AddFolder
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp \
browsemodel.cpp

HEADERS += mainwindow.h \
browsemodel.h

prajnaranjan.das
24th December 2010, 04:40
If you want to link two thing then create a new object of a class which you want to pass to your active function and pass the object show();

e.g.



void yourCurrentClassName::functionName()
{
nameOfTheClassWhichYouWantToInclude *createObjct = new nameOfTheClassWhichYouWantToInclude;
objectName->show();
}

ChrisW67
24th December 2010, 04:59
What do you mean by "make GALLERY dependent on ADDFOLDER"? They are two independent applications. If AddFolder were a library that had to be linked in to Gallery then this might make some sense.

kamlmish
24th December 2010, 08:33
I get issue
make: Leaving directory `/home/kamlesh/Gall/GALL-Build'
make: *** No rule to make target `../libs/libAddFolder.so', needed by `libAddFolder.so'. Stop.
The process "/usr/bin/make" exited with code %2.
Error while building project GALL (target: Desktop)
When executing build step 'Make'

I have created the ADDFOLDER as a library


TARGET = AddFolder
TEMPLATE = lib

CONFIG += dynamic debug

SOURCES += main.cpp\
mainwindow.cpp \
browsemodel.cpp

HEADERS += mainwindow.h \
browsemodel.h



and for GALLERY



QT += core gui

TARGET = GALLERY
TEMPLATE = app

SOURCES += main.cpp\
mainwindow.cpp \
settingstree.cpp \
displayframe.cpp \
PREVIEWFRAME.cpp \
PanelFrame.cpp \
eBeamTree.cpp \
MainFrame.cpp

HEADERS += mainwindow.h \
settingstree.h \
displayframe.h \
PREVIEWFRAME.h \
PanelFrame.h \
eBeamTree.h \
MainFrame.h

RESOURCES += \
GALL.qrc


unix {
LIBS += -L ../libs/libAddFolder.so ../libs/libAddFolder.so.1 ../libs/libAddFolder.so.1.0 ../libs/libLinkFolder.so.1.0.0
}

unix {
# adding all these versions because Qt by default creates 3 levels of linking for version control
AddFolder.target = libAddFolder.so
AddFolder.commands = $(COPY) ../libs/libAddFolder.so $$AddFolder.target
AddFolder.depends = ../libs/libAddFolder.so

AddFolder1.target = libAddFolder.so.1
AddFolder1.commands = $(COPY) ../libs/libAddFolder.so.1 $$AddFolder1.target
AddFolder1.depends = ../libs/libAddFolder.so.1

AddFolder10.target = libAddFolder.so.1.0
AddFolder10.commands = $(COPY) ../libs/libAddFolder.so.1.0 $$AddFolder10.target
AddFolder10.depends = ../libs/libAddFolder.so.1.0

AddFolder100.target = libAddFolder.so.1.0.0
AddFolder100.commands = $(COPY) ../libs/libAddFolder.so.1.0.0 $$AddFolder100.target
AddFolder100.depends = ../libs/libAddFolder.so.1.0.0

QMAKE_EXTRA_TARGETS += AddFolder AddFolder1 AddFolder10 AddFolder100
POST_TARGETDEPS += libAddFolder.so libAddFolder.so.1 libAddFolder.so.1.0 libAddFolder.so.1.0.0

QMAKE_LFLAGS += -Wl,-rpath .

}

INSTALLS += AddFolder

ChrisW67
25th December 2010, 21:17
OK, so now you change the question. Your original post has AddFolder as an app.

The LIBS variable is wrong.

At compile time:

Use INCLUDEPATH to define extra locations to be searched for header files
Use LIBS -L options to define extra locations to be searched for libraries
Use LIBS -l options to name the libs to be used.

You try to do 2 and don't do 3 at all. Each -L option takes a single directory to search for missing libraries. Each -l option names a single library to link (the name is not the file name but is related).

You seem to be confusing the other way specifying LIBS with the UNIX -L/-l style. From the qmake manual
The paths that qmake searches for libraries and the specific libraries to link against can be added to the list of values in the LIBS variable. The paths to the libraries themselves can be given, or the familiar Unix-style notation for specifying libraries and paths can be used if preferred.

You want either:


LIBS += ../libs/libAddFolder.so
OR
LIBS += -L../libs -lAddFolder
assuming that the AddFolder library is placed into the ../libs directory when it is built (this is not obviously correct from the information we have).