Demo4 - Building the code as a shared library

This fourth demo, shows how to build qdmilib into dynamic libraries, and also how to build new libraries which use qmdilib classes.

This application uses the same code as demo2, with a single difference: all the classes of qmdilib are compiled into a library (libqmdi.so.0.0.4 on Unix/Linux and qmdi0.dll on Win32), and the extended text editor and help browser into another library (libqexedit0.so.0.0.4 on Unix/Linux and qexedit0.dll on Win32). The main binary contains only the main window and the main() function.

Note that on Unix/Linux (also Mac), the application will fail to load because the loader will not be able to find the libraries. To make it work, you need to override the environment variable LD_LIBRARY_PATH to include the current directory. This example also includes a shell script which does this for you.

The main project on this demo is a subdirs project, which will build the qmdilib library, the qexedit library and finally also the main application.

This is the project file for qmdilib:

TEMPLATE = lib
TARGET=qmdi
VERSION=0.0.4
DESTDIR=../

MOC_DIR =  ../../../tmp/
RCC_DIR =  ../../../tmp/
UI_DIR =  ../../../tmp/
OBJECTS_DIR = ../../../tmp/
INCLUDEPATH += ../../../src .

# Input
HEADERS += ../../../src/actiongroup.h \
           ../../../src/actiongrouplist.h \
           ../../../src/qmdiclient.h \
           ../../../src/qmdihost.h \
           ../../../src/qmdiserver.h \
           ../../../src/qmditabwidget.h

SOURCES += ../../../src/actiongroup.cpp \
           ../../../src/actiongrouplist.cpp \
           ../../../src/qmdiclient.cpp \
           ../../../src/qmdihost.cpp \
           ../../../src/qmdiserver.cpp \
           ../../../src/qmditabwidget.cpp

This is the project file for qexedit, see how it also links the qmdi library:

TEMPLATE = lib
TARGET=qexedit
VERSION=0.0.4
DESTDIR=../

MOC_DIR =  ../../../tmp/
RCC_DIR =  ../../../tmp/
UI_DIR =  ../../../tmp/
OBJECTS_DIR = ../../../tmp/
INCLUDEPATH += . ../../../src

# Input
unix:LIBS += -lqmdi -L../
win32:LIBS += -lqmdi0 -L../

HEADERS += ../../demo2/qexeditor.h \
           ../../demo2/helpbrowse.h

SOURCES += ../../demo2/qexeditor.cpp \
           ../../demo2/helpbrowse.cpp

This is the project file for the main application, see how it links qmdi and qexedit, note also that on Unix the application name is modified, and end-users should run the shell script wrapper instead:

TEMPLATE = app
unix:TARGET = demo4.bin
win32:TARGET = demo4
DEPENDPATH += .
INCLUDEPATH += . ../../../src/ ../../demo2/
DESTDIR = ../

MOC_DIR =  ../../../tmp/
RCC_DIR =  ../../../tmp/
UI_DIR =  ../../../tmp/
OBJECTS_DIR = ../../../tmp/

# Input
unix:LIBS += -L../ -lqmdi  -lqexedit
win32:LIBS += -L../ -lqmdi0 -lqexedit0

RESOURCES += demo4.qrc
HEADERS += mainwindow4.h
SOURCES += mainwindow4.cpp  main4.cpp

See also:
Demo2 - Using the new tab widget to display dynamic menus

Small tutorial and introduction

Next: Demo5 - Building the code as a static library


Generated on Fri Jun 29 21:56:34 2007 for qmdilib by  doxygen 1.5.1