PDA

View Full Version : Creation and exploitation libraries



Trok
17th June 2009, 20:54
Hi, I have problem with libraries in qt. When I tried build static and dynamic libraries, qtcreator displayed me some form. I don't know, how I can supplement it.:confused:

If I create some library, How can I load it to my program in qt?

PaceyIV
17th June 2009, 22:26
The Project file for the library should be like this example:



PROJECT = project
TARGET = project
TEMPLATE = lib


VER_MAJ = 1
VER_MIN = 1
VER_PAT = 0
VERSION = $${VER_MAJ}.$${VER_MIN}.$${VER_PAT}

#CONFIG += staticlib
CONFIG += dll

DEBUG_SUFFIX =
RELEASE_SUFFIX =

DESTDIR = lib
OBJECTS_DIR = build/obj
MOC_DIR = build/moc

HEADERS = your headers

SOURCES = your sources


The project that use this library should have this two lines:



INCLUDEPATH += path where there are the headers of the library
LIBS += -LPATH -lNAME


Where:
PATH is the path where there is the library (.dll or .so or .a or .lib).
NAME is the name of the file without the extension

For example, if the library is locate at C:\libs\library.dll you should add this line:



LIBS += -LC:\libs -llibrary

Trok
17th June 2009, 23:23
When I build my library, some form display me. It have 4 text fields as: Name, Executable, Arguments and Working Director with $BUILDDIR. What it mean? How I must supplement it?
When I already load library to project like you, how can I call function to file?

Btw: I don't understand your first code ;/ Where I must put it?

PaceyIV
17th June 2009, 23:31
So you don't use QtCreator... I think M$ Visual Studio do the same.
The Qt project has got a project.pro file with the lists of the headers, sources, configuration settings...

Trok
17th June 2009, 23:43
Yes i know that qtcreator have list in project.pro, but I don't understand last form after built. What's mean "Executable"? How supplement it? ;/

PaceyIV
17th June 2009, 23:50
Ok. The form you're talking is in the section Project, Run settings

I don't know why Qtcreator shows you this. Maybe he can't find the executable you're compiled. It shows this also for normal project, without external library?

Trok
17th June 2009, 23:58
PaceyIV thanks for all. When I only build my library it work good. So far I compiled and run it.
It's deliver.