DCMTK
Version 3.6.1 20170228
OFFIS DICOM Toolkit
|
You may compile DCMTK with C++11 support enabled. This may increase performance since some operations can be performed in a more efficient manner, e.g. utilizing move semantics. To create a C++11 build of DCMTK, you simply need to set the appropriate compiler-flags while building it (e.g. -std=c++11). This will however not enable DCMTK to use available C++11 features that aren't implicitly used by legacy code. This is especially important regarding some C++11 classes DCMTK directly supports, for example:
Since not every compiler supports C++11, legacy implementations for the respective functionality have been created, which are enabled by default.
If you use C++11 in your project, you may want to use the native C++11 classes instead, so you don't need to convert your objects to use them with DCMTK. To do so, you need to configure DCMTK to use the C++11 STL, which is described below.
By enabling DCMTK to use the C++11 STL, you gain the following advantages:
Trying to include a DCMTK build with C++11 STL enabled from a non C++11 environment will give you the following error message:
DCMTK was configured to use the C++11 STL, but your compiler is not configured for building with C++11 features.
To reduce DCMTK's implementation complexity, the C++11 STL shall only be used if your compiler conforms closely to the C++11 Standard. As far as we know, this is currently true for the following compilers:
To enable the C++11 STL, different steps are necessary on CMake and GNU Autoconf, see the appropriate section below:
CMake detects the C++11 compilers mentioned above and knows how to enable C++11 features on these compilers. If your compiler was detected successfully, CMake will give you the following message during configure:
Info: Your compiler supports C++11. You may enable C++11 features via "DCMTK_USE_CXX11_STL" to create a C++11 build of DCMTK.
As mentioned in this message, you may enable the C++11 STL by setting DCMTK_USE_CXX11_STL
, for example via:
cmake ... -DDCMTK_USE_CXX11_STL:BOOL=ON
Doing so will give you the following message during configure:
Info: Configured DCMTK to use native C++11 features.
You may need to override the flags to enable C++11, for example to enable C++14 instead. Doing so can be done via DCMTK_CXX11_FLAGS
, for example:
cmake ... -DDCMTK_USE_CXX11_STL:BOOL=ON -DDCMTK_CXX11_FLAGS=-std=c++14
If CMake does not know how to enable C++11 on your compiler or your compiler does not support C++11 completely, you will see the following warning message when you try to enable DCMTK_USE_CXX11_STL
anyway:
DCMTK has been configured to use the C++11 STL, but the compiler does not seem to support C++11. Override this warning by setting DCMTK_CXX11_FLAGS to tell DCMTK how to enable C++11 support for your compiler.
As the message states, you need to take care about configuring your compiler for C++11 manually, for example by setting CMAKE_CXX_FLAGS
appropriately. Setting DCMTK_CXX11_FLAGS
instead will have the same result (CMake will set CMAKE_CXX_FLAGS
based on DCMTK_CXX_FLAGS
), but the warning goes away and instead you will see the following output:
Info: Enabling C++11 support with custom flags "< YOUR FLAGS >" for a potentially unsupported compiler.
Our GNU Autoconf setup understands the argument --with-cxx11-stl
, that may be used to configure DCMTK to use the C++11 STL. But this only enables API/ABI checks and maps DCMTK's functionalities to the respective STL ones. You still need to configure your compiler for C++11 manually, for example by setting the CXXFLAGS like this when using GCC 4.9:
./configure --with-cxx11-stl CXXFLAGS=-std=c++11