PDA

View Full Version : How to link a shared library to app



kamlmish
24th December 2010, 10:46
Hi
I have a to link a shared library in my app
May I know what mistake I am doing
the pro file



#-------------------------------------------------
#
# Project created by QtCreator 2010-11-29T16:54:50
#
#-------------------------------------------------

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:INCLUDEPATH += ../../libs

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

unix {
LIBS += -L ../../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




QT += gui \
core\
network \
xml

TARGET = AddFolder
TEMPLATE = lib

CONFIG += dynamic debug

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

HEADERS += mainwindow.h \
browsemodel.h



Added after 45 minutes:

The library files gets created at the path
/home/kamlesh/Test/Libs

The Application needs to be created in
/home/kamlesh/Test/Gallery

ChrisW67
25th December 2010, 20:57
Your LIBS variable is set incorrectly. (Educated guess based on the most common mistakes, error messages you didn't tell us about, and what you showed us.)

Did you search the forum before you asked this? There is plenty of information in this forum, and even a couple of recent, complete examples.

http://www.qtcentre.org/threads/36840-Problem-linking-external-libraries-to-.pro-file?highlight=link+shared+library
(particularly http://www.qtcentre.org/threads/36840-Problem-linking-external-libraries-to-.pro-file?p=169851#post169851)
http://www.qtcentre.org/threads/36432-Implement-jpegsrc.v8b.tar.gz-LINUX?highlight=link+shared+library