Failing to build DCMTK-3.6.7

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
jogerh
Posts: 37
Joined: Mon, 2022-02-28, 08:55

Failing to build DCMTK-3.6.7

#1 Post by jogerh »

I try to build DCMTK-3.6.7 tag on https://github.com/DCMTK/dcmtk.git with openssl and icu support, with cmake cmake version 3.20.21032501-MSVC_2 for Visual Studio 2019.

Unfortunately, I get an error:

Code: Select all

-- Info: STL tuple support enabled
-- Info: STL system_error support enabled
CMake Error at dcmtk/dcmtls/libsrc/CMakeLists.txt:13 (set_property):
  set_property could not find TARGET dcmtls.  Perhaps it has not yet been
  created.


CMake Error at dcmtk/dcmnet/libsrc/CMakeLists.txt:49 (set_property):
  set_property could not find TARGET dcmnet.  Perhaps it has not yet been
  created.


-- Looking for CMake command CONFIGURE_PACKAGE_CONFIG_FILE
-- Looking for CMake command CONFIGURE_PACKAGE_CONFIG_FILE - found
Introduced in

Code: Select all

a1615b246fe5837c82221052312b3eb17fb30f22 is the first bad commit
commit a1615b246fe5837c82221052312b3eb17fb30f22
Author: Jan Schlamelcher <dicom@offis.de>
Date:   Thu Mar 25 17:52:23 2021 +0100

    Introduced CMake variable DCMTK_TLS_LIBRARY_POSTFIX.

    Introduced a new advanced CMake cache variable DCMTK_TLS_LIBRARY_POSTFIX that
    allows adding a custom postfix to all file names of all libraries that change
    their ABI when linking against OpenSSL.
    Please note that this suffix is not enabled by default and must be set to an
    appropriate string in addition to enabling DCMTK_WITH_OPENSSL if you plan to
    mix TLS enabled with non TLS enabled DCMTK builds.

    This closes DCMTK issue #879.
My configuration:

Code: Select all

cmake_minimum_required(VERSION 3.8)

Project(dcmtk)

# Configure locations and naming of generated files
set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "" FORCE)
set(CMAKE_INSTALL_BINDIR "bin" CACHE STRING "" FORCE)
set(CMAKE_DEBUG_POSTFIX  "d" CACHE STRING "" FORCE)

# Build only debug and release
set(CMAKE_CONFIGURATION_TYPES "Release;Debug" CACHE STRING "" FORCE)

 # Enable multi-core builds
add_compile_options(/MP)

# Enable debug symbols output
add_compile_options(/Zi)

# Enable PDB also in release
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE    "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG")

# Remove unreferenced functions & data (https://docs.microsoft.com/en-us/cpp/build/reference/opt-optimizations)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /OPT:REF /INCREMENTAL:no")
set(CMAKE_EXE_LINKER_FLAGS    "${CMAKE_EXE_LINKER_FLAGS} /OPT:REF /INCREMENTAL:no")

# Workaround for compiling with openssl
add_definitions(-DHAVE_SSL_CTX_GET0_PARAM)

set(DCMTK_MODULES ofstd oflog dcmdata dcmimgle dcmjpeg dcmjpls dcmimage dcmtls dcmnet dcmsr dcmiod CACHE STRING "List of modules that should be built." FORCE)
set(ICU_ROOT "${CMAKE_SOURCE_DIR}/support_libraries/icu4c")
set(OPENSSL_USE_STATIC_LIBS TRUE)
set(OPENSSL_MSVC_STATIC_RT TRUE)
set(OPENSSL_ROOT_DIR "${CMAKE_SOURCE_DIR}/support_libraries/openssl")
set(WITH_OPENSSLINC "${CMAKE_SOURCE_DIR}/support_libraries/openssl")

option(BUILD_APPS "Build command line applications and test programs." OFF)
option(BUILD_SHARED_LIBS "Build with shared libraries." ON)
option(BUILD_SINGLE_SHARED_LIBRARY "Build a single DCMTK library." ON)

option(DCMTK_WITH_TIFF "Configure DCMTK with support for TIFF." OFF)
option(DCMTK_WITH_PNG "Configure DCMTK with support for PNG." OFF)
option(DCMTK_WITH_XML "Configure DCMTK with support for XML." OFF)
option(DCMTK_WITH_ZLIB "Configure DCMTK with support for ZLIB." OFF)
option(DCMTK_WITH_OPENSSL "Configure DCMTK with support for OPENSSL." ON)
option(DCMTK_WITH_SNDFILE "Configure DCMTK with support for SNDFILE." OFF)
option(DCMTK_WITH_ICONV "Configure DCMTK with support for ICONV." OFF)
option(DCMTK_WITH_ICU "Configure DCMTK with support for ICU." ON)
option(DCMTK_WITH_OPENJPEG "Configure DCMTK with support for OPENJPEG." OFF)
option(DCMTK_ENABLE_PRIVATE_TAGS "Configure DCMTK with support for DICOM private tags coming with DCMTK." OFF)
option(DCMTK_WITH_THREADS "Configure DCMTK with support for multi-threading." ON)
option(DCMTK_WITH_DOXYGEN "Build API documentation with DOXYGEN." OFF)
option(DCMTK_GENERATE_DOXYGEN_TAGFILE "Generate a tag file with DOXYGEN." OFF)
option(DCMTK_WIDE_CHAR_FILE_IO_FUNCTIONS "Build with wide char file I/O functions." ON)
option(DCMTK_WIDE_CHAR_MAIN_FUNCTION "Build command line tools with wide char main function." ON)
option(DCMTK_ENABLE_STL "Enable use of native STL classes and algorithms instead of DCMTK's own implementations." ON)

add_subdirectory(dcmtk-next)


Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Failing to build DCMTK-3.6.7

#2 Post by Michael Onken »

Thank you for the report, we will investigate this.

For now try disabling OpenSSL.

BR,
Michael

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Failing to build DCMTK-3.6.7

#3 Post by Michael Onken »

Hi,

we've checked with the team and we have this combination (compiler, OS and OpenSSL enabled) in our nightly builds and they compile and run fine. Did you start from a clean build tree?

Best,
Michael

jogerh
Posts: 37
Joined: Mon, 2022-02-28, 08:55

Re: Failing to build DCMTK-3.6.7

#4 Post by jogerh »

Thank you for a quick response Michael. My problem did not reproduce with a clean build tree. I apologise for the false alarm.

Thanks,
Jøger

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Failing to build DCMTK-3.6.7

#5 Post by Michael Onken »

Thats actually good news :P

jogerh
Posts: 37
Joined: Mon, 2022-02-28, 08:55

Re: Failing to build DCMTK-3.6.7

#6 Post by jogerh »

Hi again Michael,

Unfortunately, the alarm may not have been as false as I thought. Investigating further, it looks like BUILD_SINGLE_SHARED_LIBRARY is broken. I might be wrong again, but running the following command with a clean build tree and 'dcmtk' folder set to DCMTK-3.6.7 fails on my computer:

Code: Select all

cmake.exe -A x64 -G "Visual Studio 16 2019" -T v142 -DBUILD_SHARED_LIBS:BOOL=ON -DBUILD_SINGLE_SHARED_LIBRARY:BOOL=ON -S dcmtk -B build
Errors:

Code: Select all

CMake Error at dcmtls/libsrc/CMakeLists.txt:13 (set_property):
  set_property could not find TARGET dcmtls.  Perhaps it has not yet been
  created.


CMake Error at dcmnet/libsrc/CMakeLists.txt:49 (set_property):
  set_property could not find TARGET dcmnet.  Perhaps it has not yet been
  created.


CMake Error at dcmsign/libsrc/CMakeLists.txt:26 (set_property):
  set_property could not find TARGET dcmdsig.  Perhaps it has not yet been
  created.


CMake Error at dcmpstat/libsrc/CMakeLists.txt:51 (set_property):
  set_property could not find TARGET dcmpstat.  Perhaps it has not yet been
  created.
Best regards,
Jøger

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Failing to build DCMTK-3.6.7

#7 Post by Michael Onken »

Hi Jøger,

you are right. I see the same error on my Windows system and VS 2019, if I enable BUILD_SINGLE_SHARED_LIBRARY. I let you know once this is fixed.

BR, Michael

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

Re: Failing to build DCMTK-3.6.7

#8 Post by Marco Eichelberg »

I have today committed a fix for the BUILD_SINGLE_SHARED_LIBRARY build. If that successfully passes our nightly build, it should be visible on the public git server in a few days.
In the interim time, here's the patch:

Code: Select all

diff --git a/dcmdata/libdcxml/xml2dcm.cc b/dcmdata/libdcxml/xml2dcm.cc
index 84541f9c8..aa6c4aad6 100644
--- a/dcmdata/libdcxml/xml2dcm.cc
+++ b/dcmdata/libdcxml/xml2dcm.cc
@@ -39,12 +39,12 @@

 // This function is also used in dcmsr, try to stay in sync!
 #if defined(HAVE_VSNPRINTF) && defined(HAVE_PROTOTYPE_VSNPRINTF)
-extern "C" void errorFunction(void * ctx, const char *msg, ...)
+extern "C" void xml2dcm_errorFunction(void * ctx, const char *msg, ...)
 {
     // Classic C requires us to declare variables at the beginning of the function.
     OFString &buffer = *OFstatic_cast(OFString*, ctx);
 #else
-extern "C" void errorFunction(void * /* ctx */, const char *msg, ...)
+extern "C" void xml2dcm_errorFunction(void * /* ctx */, const char *msg, ...)
 {
 #endif

@@ -122,7 +122,7 @@ void DcmXMLParseHelper::initLibrary()
     /* check for compatible libxml version */
     LIBXML_TEST_VERSION

-    /* temporary buffer needed for errorFunction - more detailed explanation there */
+    /* temporary buffer needed for xml2dcm_errorFunction - more detailed explanation there */
     OFString tmpErrorString;

     /* initialize the XML library (only required for MT-safety) */
@@ -140,7 +140,7 @@ void DcmXMLParseHelper::initLibrary()

     /* enable libxml warnings and error messages */
     xmlGetWarningsDefaultValue = 1;
-    xmlSetGenericErrorFunc(&tmpErrorString, errorFunction);
+    xmlSetGenericErrorFunc(&tmpErrorString, xml2dcm_errorFunction);
 }


@@ -657,13 +657,13 @@ OFCondition DcmXMLParseHelper::validateXmlDocument(xmlDocPtr doc)
     OFCondition result = EC_Normal;
     DCMDATA_INFO("validating XML document ...");
     xmlGenericError(xmlGenericErrorContext, "--- libxml validating ---\n");
-    /* temporary buffer needed for errorFunction - more detailed explanation there */
+    /* temporary buffer needed for xml2dcm_errorFunction - more detailed explanation there */
     OFString tmpErrorString;
     /* create context for document validation */
     xmlValidCtxt cvp;
     cvp.userData = &tmpErrorString;
-    cvp.error = errorFunction;
-    cvp.warning = errorFunction;
+    cvp.error = xml2dcm_errorFunction;
+    cvp.warning = xml2dcm_errorFunction;
     /* validate the document */
     const int valid = xmlValidateDocument(&cvp, doc);
     xmlGenericError(xmlGenericErrorContext, "-------------------------\n");
diff --git a/dcmnet/libsrc/CMakeLists.txt b/dcmnet/libsrc/CMakeLists.txt
index 7ab209616..3d184a04c 100644
--- a/dcmnet/libsrc/CMakeLists.txt
+++ b/dcmnet/libsrc/CMakeLists.txt
@@ -46,4 +46,7 @@ DCMTK_ADD_LIBRARY(dcmnet

 DCMTK_TARGET_LINK_MODULES(dcmnet ofstd oflog dcmdata)
 DCMTK_TARGET_LINK_LIBRARIES(dcmnet ${WRAP_LIBS})
-set_property(TARGET dcmnet PROPERTY OUTPUT_NAME "dcmnet${DCMTK_TLS_LIBRARY_POSTFIX}")
+
+if (TARGET dcmnet)
+  set_property(TARGET dcmnet PROPERTY OUTPUT_NAME "dcmnet${DCMTK_TLS_LIBRARY_POSTFIX}")
+endif()
diff --git a/dcmpstat/libsrc/CMakeLists.txt b/dcmpstat/libsrc/CMakeLists.txt
index 9ba85081a..7a23b1c64 100644
--- a/dcmpstat/libsrc/CMakeLists.txt
+++ b/dcmpstat/libsrc/CMakeLists.txt
@@ -48,4 +48,7 @@ DCMTK_ADD_LIBRARY(dcmpstat
 )

 DCMTK_TARGET_LINK_MODULES(dcmpstat ofstd oflog dcmdata dcmiod dcmimgle dcmimage dcmnet dcmdsig dcmtls dcmsr dcmqrdb)
-set_property(TARGET dcmpstat PROPERTY OUTPUT_NAME "dcmpstat${DCMTK_TLS_LIBRARY_POSTFIX}")
+
+if (TARGET dcmpstat)
+  set_property(TARGET dcmpstat PROPERTY OUTPUT_NAME "dcmpstat${DCMTK_TLS_LIBRARY_POSTFIX}")
+endif()
diff --git a/dcmsign/libsrc/CMakeLists.txt b/dcmsign/libsrc/CMakeLists.txt
index 7bb4257de..0faefeeb2 100644
--- a/dcmsign/libsrc/CMakeLists.txt
+++ b/dcmsign/libsrc/CMakeLists.txt
@@ -23,4 +23,7 @@ DCMTK_ADD_LIBRARY(dcmdsig

 DCMTK_TARGET_LINK_MODULES(dcmdsig ofstd dcmdata)
 DCMTK_TARGET_LINK_LIBRARIES(dcmdsig ${OPENSSL_LIBS})
-set_property(TARGET dcmdsig PROPERTY OUTPUT_NAME "dcmdsig${DCMTK_TLS_LIBRARY_POSTFIX}")
+
+if (TARGET dcmdsig)
+  set_property(TARGET dcmdsig PROPERTY OUTPUT_NAME "dcmdsig${DCMTK_TLS_LIBRARY_POSTFIX}")
+endif()
diff --git a/dcmtls/libsrc/CMakeLists.txt b/dcmtls/libsrc/CMakeLists.txt
index 704e1991b..b7276e9ea 100644
--- a/dcmtls/libsrc/CMakeLists.txt
+++ b/dcmtls/libsrc/CMakeLists.txt
@@ -10,4 +10,7 @@ DCMTK_ADD_LIBRARY(dcmtls

 DCMTK_TARGET_LINK_MODULES(dcmtls ofstd dcmdata dcmnet)
 DCMTK_TARGET_LINK_LIBRARIES(dcmtls ${OPENSSL_LIBS})
-set_property(TARGET dcmtls PROPERTY OUTPUT_NAME "dcmtls${DCMTK_TLS_LIBRARY_POSTFIX}")
+
+if (TARGET dcmtls)
+  set_property(TARGET dcmtls PROPERTY OUTPUT_NAME "dcmtls${DCMTK_TLS_LIBRARY_POSTFIX}")
+endif()

jogerh
Posts: 37
Joined: Mon, 2022-02-28, 08:55

Re: Failing to build DCMTK-3.6.7

#9 Post by jogerh »

Thank you Marco! This is great news.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest