DICOM @ OFFIS

Discussion Forum for OFFIS DICOM Tools - For registration, send email with desired user name to the OFFIS DICOM team
It is currently Mon, 2017-10-23, 12:35

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri, 2017-10-06, 20:05 
Offline

Joined: Mon, 2007-10-29, 22:41
Posts: 3
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:
/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:
//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:
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:
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.


Top
 Profile  
 
PostPosted: Sat, 2017-10-07, 20:15 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1867
Location: Oldenburg, Germany
Could you check whether the current git version works?

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


Top
 Profile  
 
PostPosted: Mon, 2017-10-09, 14:25 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Mon, 2014-03-03, 09:51
Posts: 216
Location: Oldenburg, Germany
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.


Top
 Profile  
 
PostPosted: Tue, 2017-10-10, 14:32 
Offline

Joined: Mon, 2007-10-29, 22:41
Posts: 3
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?


Top
 Profile  
 
PostPosted: Tue, 2017-10-10, 14:47 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Mon, 2014-03-03, 09:51
Posts: 216
Location: Oldenburg, Germany
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group