DCMTK static library compilation (+zlib +openssl)

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
gendicomarme
Posts: 6
Joined: Fri, 2023-11-17, 12:58

DCMTK static library compilation (+zlib +openssl)

#1 Post by gendicomarme »

Good day.

I have been attempting to compile DCMTK on and off for the past year with poor success.

One of the design principles of my application is to be "self contained" and not rely on DLL which may be lost, wrong version, et.c. So I have chosen static libraries.

In building DCMTK with zlib and openssl (reviewing the FAQ carefully https://brandres.medium.com/setup-dcmtk ... b3a40c9a54
https://forum.dcmtk.org/viewtopic.php?s ... bcfd22ae76 https://forum.dcmtk.org/viewtopic.php?t=36

I find that am still unable to link the library within my application.

The current error is unresolved external symbol SSL_get1_peer_certificate, EVP_PKEY_get_base_id, EVP_PKEY_get_bits (condensed for readability and patience.)

So. Can someone suggest a series of steps to correctly compile dcmtk static with zlib and openssl?

Thank you in advance for your consideration. May the code complete you.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1507
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: DCMTK static library compilation (+zlib +openssl)

#2 Post by Marco Eichelberg »

You fail to mention the operating system on which you are developing. For now I will assume that you intend to compile on Windows.

Note that we provide pre-compiled versions of all external libraries for various Visual Studio compilers and compiler settings. Most of these are static libraries, with the exception of OpenSSL, which uses two DLLs.
If that is unacceptable for you, you will first have to produce a fully static library version of OpenSSL for DCMTK to link against.
On Posix operating systems, this can be achieved by passing certain options to OpenSSL's "config" script:

Code: Select all

./config no-shared no-module
This should also be possible on Windows, although I have never tried:

Code: Select all

perl Configure VC-WIN64A no-shared no-module
In any case, the linker errors you see are caused by missing OpenSSL libraries.

gendicomarme
Posts: 6
Joined: Fri, 2023-11-17, 12:58

Re: DCMTK static library compilation (+zlib +openssl)

#3 Post by gendicomarme »

Current compilation attempt looks like this. :

Code: Select all

PS C:\repos\untitledMigrationService\packages\openssl> C:\strawberry\perl\bin\perl.exe Configure VC-WIN64A no-shared no-module

Failure!  build file wasn't produced.
Please read INSTALL and associated NOTES files.  You may also have to look over
your available compiler tool chain or change your configuration.

***** Unsupported options: no-module

What am I missing?

gendicomarme
Posts: 6
Joined: Fri, 2023-11-17, 12:58

Re: DCMTK static library compilation (+zlib +openssl)

#4 Post by gendicomarme »

It would appear the make static option /static is deprecated after visual studio 2017. Not sure if this is related.

LINK : warning LNK4044: unrecognized option '/static'; ignored [C:\repos\untitledMigrationService\packages\dcmtk\build\dcmpstat\apps\dcmpsmk.vcxproj]
LINK : warning LNK4044: unrecognized option '/static'; ignored [C:\repos\untitledMigrationService\packages\dcmtk\build\dcmpstat\apps\dcmpschk.vcxproj]
LINK : warning LNK4044: unrecognized option '/static'; ignored [C:\repos\untitledMigrationService\packages\dcmtk\build\dcmpstat\apps\dcmprscp.vcxproj]
LINK : warning LNK4044: unrecognized option '/static'; ignored [C:\repos\untitledMigrationService\packages\dcmtk\build\dcmpstat\apps\dcmpssnd.vcxproj]

I tried to correct it with an search/replace, but It did not resolve the problem.

"Patch the newer version of Visual Studio which uses 2022 semantics namely /mt /mtd as static is deprecated"
Get-ChildItem -Path "C:\repos\untitledMigrationService\packages\dcmtk\build" -Filter *.vcxproj -Recurse | ForEach-Object {
(Get-Content $_.FullName) -replace '/static', '/MTd' | Set-Content $_.FullName
}

gendicomarme
Posts: 6
Joined: Fri, 2023-11-17, 12:58

Re: DCMTK static library compilation (+zlib +openssl)

#5 Post by gendicomarme »

Iteration 2:

"Patch the newer version of Visual Studio which uses 2022 semantics namely /mt /mtd as static is deprecated"
Get-ChildItem -Path "./dcmtk" -Recurse -Filter "CMakeLists.txt" | ForEach-Object {
Copy-Item $_.FullName "$($_.FullName).backup"
$content = Get-Content $_.FullName
$newLine = 'set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")'
if ($content -notcontains $newLine) {
$content = @($newLine) + $content
$content | Set-Content $_.FullName
}
}

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest