3.6.2 CXX11 fails on Linux; patch suggestions included

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
BudricB
Posts: 3
Joined: Mon, 2007-10-29, 22:41

3.6.2 CXX11 fails on Linux; patch suggestions included

#1 Post by BudricB » Fri, 2017-10-06, 20:05

Hi,

I'm trying to compile 3.6.2 tag on Linux with the following cmake variables: -DDCMTK_ENABLE_CXX11=ON -DDCMTK_ENABLE_STL=ON. The error(s) I get when generating make are along the lines of:

Code: Select all

/tmp/dcmtk/config/tests/../math.cc:108:12: error: '::isinf' has not been
  declared
       return ::isinf( f );
The problem is that std::isinf (and std::isnan) are available, but are erroneously not found by CheckFunctionWithHeaderExists.cmake, and the fallback math.cc implementation of simply calling ::isinf is incorrect (it is indeed std::isinf) with these flags.

I debugged the code that checks for function existence and the generated code is basically:

Code: Select all

//bunch of headers omitted
int main()
{
std::isnan;return 0;
}

/*
manually checking with gcc identifies the problem
CheckSymbolExists_std__isnan.cxx:29:11: error: statement cannot resolve address of overloaded function
 std::isnan;return 0;
*/
Which fails to compile because std::isnan exists but is a template - and needs some template argument.

Changing CMake/GenerateDCMTKConfigure.cmaketo checks to supply some kind of template argument appears to resolve the issue. CHECK_FUNCTIONWITHHEADER_EXISTS(std::isinf<double> "${HEADERS}" HAVE_PROTOTYPE_STD__ISINF) appear to solve the problem.

The patch:

Code: Select all

diff --git a/CMake/GenerateDCMTKConfigure.cmake b/CMake/GenerateDCMTKConfigure.cmake
index 19fb179..ab36c94 100755
--- a/CMake/GenerateDCMTKConfigure.cmake
+++ b/CMake/GenerateDCMTKConfigure.cmake
@@ -571,9 +571,9 @@ ENDIF(WIN32 AND NOT CYGWIN)
   CHECK_FUNCTIONWITHHEADER_EXISTS(isinf "${HEADERS}" HAVE_PROTOTYPE_ISINF)
   CHECK_FUNCTIONWITHHEADER_EXISTS(isnan "${HEADERS}" HAVE_PROTOTYPE_ISNAN)
   CHECK_FUNCTIONWITHHEADER_EXISTS(finite "${HEADERS}" HAVE_PROTOTYPE_FINITE)
-  CHECK_FUNCTIONWITHHEADER_EXISTS(std::isinf "${HEADERS}" HAVE_PROTOTYPE_STD__ISINF)
-  CHECK_FUNCTIONWITHHEADER_EXISTS(std::isnan "${HEADERS}" HAVE_PROTOTYPE_STD__ISNAN)
-  CHECK_FUNCTIONWITHHEADER_EXISTS(std::finite "${HEADERS}" HAVE_PROTOTYPE_STD__FINITE)
+  CHECK_FUNCTIONWITHHEADER_EXISTS(std::isinf<double> "${HEADERS}" HAVE_PROTOTYPE_STD__ISINF)
+  CHECK_FUNCTIONWITHHEADER_EXISTS(std::isnan<double> "${HEADERS}" HAVE_PROTOTYPE_STD__ISNAN)
+  CHECK_FUNCTIONWITHHEADER_EXISTS(std::finite<double> "${HEADERS}" HAVE_PROTOTYPE_STD__FINITE)
   CHECK_FUNCTIONWITHHEADER_EXISTS(flock "${HEADERS}" HAVE_PROTOTYPE_FLOCK)
   CHECK_FUNCTIONWITHHEADER_EXISTS(gethostbyname "${HEADERS}" HAVE_PROTOTYPE_GETHOSTBYNAME)
   CHECK_FUNCTIONWITHHEADER_EXISTS(gethostbyname_r "${HEADERS}" HAVE_PROTOTYPE_GETHOSTBYNAME_R)
Additional suggestion to make debugging these things easier by splitting each check into a separate file instead of CheckSymbolExists.cxx

Code: Select all

diff --git a/CMake/CheckFunctionWithHeaderExists.cmake b/CMake/CheckFunctionWithHeaderExists.cmake
index 1b95ac4..86de035 100644
--- a/CMake/CheckFunctionWithHeaderExists.cmake
+++ b/CMake/CheckFunctionWithHeaderExists.cmake
@@ -23,13 +23,15 @@ MACRO(CHECK_FUNCTIONWITHHEADER_EXISTS SYMBOL FILES VARIABLE)
     SET(CHECK_SYMBOL_EXISTS_CONTENT
       "${CHECK_SYMBOL_EXISTS_CONTENT}\nint main()\n{\n${SYMBOL};return 0;\n}\n")
 
-    FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.cxx
+    STRING(REGEX REPLACE "[:<>()]" "_" SYMBOL_FILENAME_SANITIZED ${SYMBOL})
+
+    FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists_${SYMBOL_FILENAME_SANITIZED}.cxx
       "${CHECK_SYMBOL_EXISTS_CONTENT}")
 
     MESSAGE(STATUS "Looking for prototype of ${SYMBOL}")
     TRY_COMPILE(${VARIABLE}
       "${CMAKE_BINARY_DIR}"
-      "${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.cxx"
+      "${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists_${SYMBOL_FILENAME_SANITIZED}.cxx"
       CMAKE_FLAGS
       -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_SYMBOL_EXISTS_FLAGS}
       "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}"
@@ -50,7 +52,7 @@ MACRO(CHECK_FUNCTIONWITHHEADER_EXISTS SYMBOL FILES VARIABLE)
       FILE(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
         "Determining if the ${SYMBOL} "
         "exist failed with the following output:\n"
-        "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.cxx:\n"
+        "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists_${SYMBOL_FILENAME_SANITIZED}.cxx:\n"
         "${CHECK_SYMBOL_EXISTS_CONTENT}\n")
     ENDIF(${VARIABLE})
   ENDIF(NOT DEFINED "${VARIABLE}")
Aside from compiling I haven't done extensive testing beyond this with STL and C++11.

Thanks.

J. Riesmeier
DCMTK Developer
Posts: 2008
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: 3.6.2 CXX11 fails on Linux; patch suggestions included

#2 Post by J. Riesmeier » Sat, 2017-10-07, 20:15

Could you check whether the current git version works?

Here is the relevant commits: http://git.dcmtk.org/?p=dcmtk.git;a=blo ... 1ccca4f1ad

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 284
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: 3.6.2 CXX11 fails on Linux; patch suggestions included

#3 Post by Jan Schlamelcher » Mon, 2017-10-09, 14:25

It seems Jörg misunderstood your question, since the commit he quoted does not help this problem in anyway. However, we've already received information about this problem from several sources, see for example this: https://github.com/commontk/DCMTK/commi ... t-23655023 . We will integrate one of the proposed patches into DCMTK on the near future, still, thanks for proposing your solution.

BudricB
Posts: 3
Joined: Mon, 2007-10-29, 22:41

Re: 3.6.2 CXX11 fails on Linux; patch suggestions included

#4 Post by BudricB » Tue, 2017-10-10, 14:32

Thanks,

Didn't know about commontk github repo. Is there a preferred place (github or otherwise) to submit tickets/patches or is this forum still the place?

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 284
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: 3.6.2 CXX11 fails on Linux; patch suggestions included

#5 Post by Jan Schlamelcher » Tue, 2017-10-10, 14:47

The forum/email is still the preferred place and git.dcmtk.org is still our main (official) git repository. We've recently introduced https://github.com/DCMTK/dcmtk as an official mirror. All other GitHub etc. mirrors are not maintained by us and most likely/often outdated.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest