How to link one application to another
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
Code:
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
Code:
QT += core gui
TARGET = AddFolder
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
browsemodel.cpp
HEADERS += mainwindow.h \
browsemodel.h
Re: How to link one application to another
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.
Code:
void yourCurrentClassName::functionName()
{
nameOfTheClassWhichYouWantToInclude *createObjct = new nameOfTheClassWhichYouWantToInclude;
objectName->show();
}
Re: How to link one application to another
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.
Re: How to link one application to another
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
Code:
TARGET = AddFolder
TEMPLATE = lib
CONFIG += dynamic debug
SOURCES += main.cpp\
mainwindow.cpp \
browsemodel.cpp
HEADERS += mainwindow.h \
browsemodel.h
and for GALLERY
Code:
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
Re: How to link one application to another
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
Quote:
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:
Code:
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).