PDA

View Full Version : building and using a library



bossy
6th January 2012, 00:00
Hi,
I would like to find a basic example on how to build a library and use it in a program with Qt creator debugger mode. All my attempt have failed so far even with other people postings I could not get a clear step by step procedure that work.

Thanks

ChrisW67
6th January 2012, 02:13
What part of this are you experiencing difficulty with?

Building a library using Qt: see Building a Library and Creating Shared Libraries.
Building a Qt application that uses that library: see Declaring Other Libraries
Debugging a program using that library for faults in the library: build the library and application in debug mode.

This has all been covered numerous times in this forum and based on having at least a basic understanding of how programs are compiled/linked.

bossy
6th January 2012, 16:08
the library seems to build properly(no errors), the i copy the liblibrary2.a, library2.dll and header files in the "includepath" folder of my program, the .pro looks like this:
QT += core gui

TARGET = TEST3
TEMPLATE = app

INCLUDEPATH = C:/QtSDK/Examples/4.7/mainwindows/test/library2

SOURCES += main.cpp\
mainwindow.cpp
LIBS+= -LC:/QtSDK/Examples/4.7/mainwindows/test/library2 -lliblibrary2

HEADERS += mainwindow.h

when i attempt to build i get this error:
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lliblibrary2
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\TEST3.exe] Error 1
mingw32-make: *** [debug] Error 2
FORMS += mainwindow.ui

if i remove liblibrary.a from the folder then it complains about undefined class...

thanks for your help

Lykurg
6th January 2012, 23:39
-lliblibrary2
Seems that there is a "lib" too much...

bossy
8th January 2012, 18:06
i swear I tried this before! seems to work fine now, much to learn I have...

sorry about the rookie question and thanks for replying