How can I create the DCMTK libraries as shared objects (.so-files) which are dynamically loaded when the DCMTK applications are started?
This depends on your C++ compiler and operating system. When building shared objects containing C++ code, special handling for templates and constructors/destructors of global variables is required. Therefore, on most systems the shared object must be created with the C++ compiler, not with "ld". If you are using gcc on a platform where the "-shared" flag is supported, the following steps will create a "dynamic" DCMTK:
- run rootconf and configure (see the INSTALL file).
- edit the file 'config/Makefile.def' to include the following settings:
CFLAGS= -fPIC -O2
CXXFLAGS= -fPIC -O2
ARFLAGS= -shared -o
- build and install the toolkit with "make", "make install" and "make install-lib".
- make sure that the environment variable LD_LIBRARY_PATH contains the directory where the DCMTK shared objects are installed.
For Mac OS X, "-shared" should be replaced by "-dynamiclib" in step 2.