DCMTK (MD version) compilation and installation + VS2015

Visual Studio 2015+cmake compile and install MD version of DCMTK

The next chapter DCMTK (MD version), QT, VS2015 to write and browse medical image applications-reading module    https://blog.csdn.net/chaoenhu/article/details/101704350

Compilation-free, go directly to the official website of the Radiomics Group of the Key Laboratory of Molecular Imaging of the Chinese Academy of Sciences to download the compiled file

http://www.radiomics.net.cn/platform/version/6

One, the compilation environment

The compilation machine of this article is Windows10 64-bit system, using VS2015 and cmake3.7.2 to compile the DCMTK source code into a 64-bit package (the runtime library is MD or MDd).

Note (reference): /MT and /MTd indicate the static lib version of the multithreaded CRT library. This option will fully embed the runtime library as a static lib at compile time. The executable file generated by this option does not require the participation of the runtime library dll when it runs, and will obtain a slight performance improvement, but the resulting binary code becomes very bloated due to the huge runtime library implementation. When a project is embedded in multiple projects in the form of a static link library, it may cause multiple copies of the memory management of the runtime library, which will eventually lead to the fatal "Invalid Address specified to RtlValidateHeap" problem. In addition, the /MT and /MTd options are no longer supported in managed C++ and CLI.

    /MD and /MDd indicate that the dynamic dll version of the multi-threaded CRT library is used, which will make the application use the specific version of the multi-threaded DLL of the runtime library. When linking, the import library MSVCRT.lib of the runtime library MSVCRxx.DLL will be linked according to the traditional VC link dll method. At runtime, the corresponding version of the VC runtime library redistributable component package will be installed (of course, these runtime libraries The dll can also be placed in the application directory). Because the /MD and /MDd methods will not link the runtime library to the executable file, it can effectively reduce the size of the executable file. When multiple projects are operated in MD mode, the same heap will be used internally, memory management will be simplified, and cross-module memory management problems can also be alleviated.

    Conclusion: /MD and /MDd will be the trend, /ML and /MLd methods please give up in time, and /MT and /MTd should not be used unless necessary.

2. Download files

1) DCMTK package dcmtk-3.6.2.tar.gz download

Direct download link or download the latest version http://www.dcmtk.org/dcmtk.php.en

2) Support library package dcmtk-3.6.2-win64-support_MD-msvc-14.0.zip download

Direct download link or download the latest version http://www.dcmtk.org/dcmtk.php.en

3) Cmake3.10 download

Download directly , unzip, enter the bin folder, and click cmake-gui.exe.

Official website: https://cmake.org/download/

Three, use cmake to build VS2015 project

  • Click cmake-gui.exe to open the cmake interface and close all programs related to VS.
  • In where is the source code:, select the folder of the dcmtk source code, that is, the decompression path of the DCMTK3.6.2 package: E:/workspace/DCMTK20171009/dcmtk-3.6.2
  • In where to build the binaries:, select the folder where you want to store the build results (new empty folder), E:/workspace/DCMTK20171009/dcmtk-msvc15, check Grouped and Advanced

  • Click Configure , select the compilation environment Visual Studio 14 2015 Win64 , click Finish , and wait for the progress to complete.

  • After the progress bar is completed, modify the parameters, as shown in the figure below:

The specific parameters in the figure are as follows:

 

MD/MDd setting (important) (to prevent errors three)

    set "DCMTK_OVERWRITE _WIN32_COMPILER_FLAGS" to "OFF"

Xml support:

"DCMTK_WITH_XML" "ON"

"WITH_LIBXMLINC" The location of the xml in the unzipped support library/dcmtk-3.6.2-win64-support_MD-msvc-14.0/libxml2-2.9.4

libpng support:

set "DCMTK_WITH_PNG" to "ON" and set "WITH_LIBPNGINC"

My E:/workspace/DCMTK20171009/dcmtk-3.6.2-win64-support_MD-msvc-14.0/libpng-1.6.30

libtiff support:

set "DCMTK_WITH_TIFF" to "ON" and set "WITH_LIBTIFFINC"

My E:/workspace/DCMTK20171009/dcmtk-3.6.2-win64-support_MD-msvc-14.0/libtiff-4.0.8

OpenSSL support:

set "DCMTK_WITH_OPENSSL" to "ON" and set "WITH_OPENSSLINC"

E:/workspace/DCMTK20171009/dcmtk-3.6.2-win64-support_MD-msvc-14.0/openssl-1.1.0f

zlib support:

set "DCMTK_WITH_ZLIB" to "ON" and set "WITH_ZLIBINC"

My E:/workspace/DCMTK20171009/dcmtk-3.6.2-win64-support_MD-msvc-14.0/zlib-1.2.11

libiconv support:

set "DCMTK_WITH_ICONV" to "ON" and set "WITH_LIBICONVINC"

My E:/workspace/DCMTK20171009/dcmtk-3.6.2-win64-support_MD-msvc-14.0/libiconv-1.15

else

DCMTK_ENBABLE_CHARSET_CONVERSION <disable>

Other support libraries are closed, such as ICU.
  • After modifying the parameters, click " configure ", the progress is completed, click Generate , and after completion, the VS project file is produced in the dcmtk-msvc15 folder, and you can click Open Project to  open it.

Four, compile and install

  1. Open the properties page (right-click properties) of a project (such as dcm2pnm), check whether the character set (Properties -> Configuration Properties -> General) is a multi-byte character set, and run the library (Properties -> Configuration Properties -> C/C++->Code generation) is MDd (under Debug) or MD (under release), if it proves that the project is successfully generated.

  • Compile: Build->Batch Build->Select the ALL_BUILD project you need to configure, and click Build on the right. The figure below is to build the Debug version, and finally build: 95 successful.

 

  • Installation: Build->Batch Build->Select the INSTALL project you need to configure, and click Build on the right. The figure below installs the Debug version, which is installed by default in C:/ProgramFiles/DCMTK/. Modify to other disks. Please refer to the error One solution two

Five, error collection

Error 1: The following error occurred when generating the INSTALL project

------ Build has started: Project: INSTALL, Configuration: Debug x64 ------

-- Install configuration: "Debug"

CMake Error at cmake_install.cmake:31 (file):

file cannot create directory: C:/Program Files/DCMTK/include/dcmtk/config.

Maybe need administrative privileges.

solution:

  1. Start VS2015 as an administrator and rebuild.

  2. Modify the cmake_install.cmake file in the solution path (open in text mode, I use NotePad++), modify the installation path C:/Program Files/DCMTK/ to the D drive as shown in the figure below, clean the solution and regenerate

Error 2: When generating INSTALL project, the following error occurred

solution:

  1. Copy the dll under the folder dcmtk-3.6.2-win64-support_MD-msvc-14.0\openssl-1.1.0f\bin to the installation directory D:/Program Files/DCMTK/bin.

  2. Modify the cmake_install.cmake file in the folder dcmnet/apps under the solution path, modify dcmtkeay.dll to "dcmtkcrypto_d-1_1-x64.dll" and modify dcmtkssl.dll to "dcmtkssl_d-1_1-x64.dll" as shown below

Error three runtime library (MT MD) conflict

Cause various errors, such as warning LNK4098: The default library "MSVCRT" conflicts with other libraries; use /NODEFAULTLIB:library

Such as: LNK2001 unresolved external symbols __imp_*

Solution: match runtime with support library runtime

 Six, test examples

Test code

 

 
  1. #include"dcmtk/config/osconfig.h"

  2.  
  3. #include"dcmtk/dcmdata/dctk.h"

  4.  
  5. #include<iostream>

  6.  
  7.  
  8.  
  9. usingnamespace std;

  10.  
  11. int main()

  12.  
  13. {

  14.  
  15. DcmFileFormat fileformat;

  16.  
  17. OFCondition oc = fileformat.loadFile("111.dcm");

  18.  
  19. if (oc.good()) {

  20.  
  21. OFString patientName;

  22.  
  23. if (fileformat.getDataset()->findAndGetOFString(DCM_PatientName, patientName).good())

  24.  
  25. {

  26.  
  27. cout <<"Patient Name:"<< patientName.data()<<endl;

  28.  
  29. }

  30.  
  31. }

  32.  
  33.  
  34.  
  35. system("pause");

  36.  
  37.  
  38.  
  39. return 0;

  40.  
  41. }

 

 

 

 

 

result:

Configuration Environment

 

Add dependencies Iphlpapi.lib; ws2_32.lib; wsock32.lib; netapi32.lib; ofstd.lib; oflog.lib; dcmdata.lib; zlib_d.lib in order.

Iphlpapi.lib; ws2_32.lib; wsock32.lib; netapi32.lib; is the system library file

ofstd.lib; oflog.lib; dcmdata.lib; library files generated by DCMTK

zlib_d.lib supports the library file in the package and moves it to the location of the library file generated by DCMTK

 

Test Data

Download the test data (111.dcm) using the link below

http://www.casmi.science/index.php/s/mAn8XKYRd04FVIH

 Description

This document is only for communication and learning. It was compiled at 18:06, Tuesday, October 10, 2017. Please quote for reprinting. If you have any questions, send an email to [email protected]!  

Download the PDF version of this article   http://download.csdn.net/download/chaoenhu/10015394

 

Compilation-free, go directly to the official website of the Radiomics Group of the Key Laboratory of Molecular Imaging of the Chinese Academy of Sciences to download the compiled file

http://www.radiomics.net.cn/platform/version/6

The next chapter DCMTK (MD version), QT, VS2015 to write and browse medical image applications-reading module    https://blog.csdn.net/chaoenhu/article/details/101704350

further study

table of Contents:

Start   "DCMTK (MD version) compilation and installation + VS2015"

The first chapter  "DCMTK (MD version), QT, VS2015 writing Dicom sequence browsing application-new project, configuration environment"

Chapter Two  "Chapter Two Dicom Image Browser Based on QT and DCMTK---Interface Design"

Chapter 3  "Dicom Image Viewer Based on QT and DCMTK---Single Dicom Image Reading Class"

Chapter 4  "Dicom Image Viewer Based on QT and DCMTK---Check the Number of Dicom Sequences in the Folder"

Chapter 5 " Dicom Image Browser Based on QT and DCMTK---Dicom Image Sequence Class "

Chapter 6 " Dicom Image Browser Based on QT and DCMTK---Dicom View Class "

Chapter 7   "Dicom Image Viewer Based on QT and DCMTK---Ending"

Guess you like

Origin blog.csdn.net/a8039974/article/details/108320555