DICOM @ OFFIS

Discussion Forum for OFFIS DICOM Tools - For registration, send email with desired user name to the OFFIS DICOM team
It is currently Thu, 2018-04-26, 22:03

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: External libs with mingw
PostPosted: Mon, 2016-02-08, 14:42 
Offline

Joined: Wed, 2015-09-02, 09:24
Posts: 34
Hi,

I am using a MinGW compiler suite on Windows with prepared external libs (OpenSSL, zlib, libtiff, libpng and libxml2) in place. However, CMake wasn't able to pick them up even if they are on the system search paths (CPATH, LIBRARY_PATH, etc). Even more, if I chose to specify the paths explicitly with "WITH_LIBXMLINC", "WITH_LIBPNGINC", etc, CMake still cannot find correct files because I think it was trying to look for "*.lib" instead of "*.a". Is there a way to get around this? Thanks!


Top
 Profile  
 
PostPosted: Mon, 2016-02-08, 18:07 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Mon, 2014-03-03, 09:51
Posts: 231
Location: Oldenburg, Germany
Sorry, I wanted to have commited this some time ago, but I did not come to do serious testing with it:
Code:
diff --git a/CMake/3rdparty.cmake b/CMake/3rdparty.cmake
index 9fcca77..b40f88b 100755
--- a/CMake/3rdparty.cmake
+++ b/CMake/3rdparty.cmake
@@ -1,4 +1,4 @@
-IF(WIN32)
+IF(WIN32 AND NOT MINGW)

   # For Windows, we don't used FIND_PACKAGE because DCMTK usually is used with its
   # own set of 3rd-party support libraries that can be downloaded from DCMTK's
@@ -139,7 +139,7 @@ IF(WIN32)
     ENDIF(WITH_LIBICONVINC)
   ENDIF(DCMTK_WITH_ICONV)

-ELSE(WIN32)
+ELSE(WIN32 AND NOT MINGW)

   # Find TIFF
   IF(DCMTK_WITH_TIFF)

This patch effectively changes the used find_package mechanism so that MinGW is handled the same as UNIX, which always worked for me.


Top
 Profile  
 
PostPosted: Sun, 2016-07-03, 19:41 
Offline

Joined: Wed, 2015-09-02, 09:24
Posts: 34
I finally had time to try this again :-)

1) I first updated the "3rdparty.make" file:
IF(WIN32) to IF(WIN32 AND NOT MINGW)
ELSE(WIN32) to ELSE(WIN32 AND NOT MINGW)
2) Prepared libtiff etc, and then configure dcmtk with CMake/MinGW
3) in CMake, turned on "DCMTK_WITH_TIFF" etc;
4) in CMake, set "WITH_LIBTIFFINC" etc to my $(PATH_INSTALL), which contains lib/libtiff.a etc and include/tiff.h etc

However, CMake still reported that libtiff couldn't be located. Same occurred for libpng, libiconv, etc
May you have any idea where I might get wrong? You said it would be treated exactly as in Unix. Does it also apply to mingw in windows? Or msys or something? Thanks


Top
 Profile  
 
PostPosted: Mon, 2016-07-04, 16:40 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Mon, 2014-03-03, 09:51
Posts: 231
Location: Oldenburg, Germany
You're setting the wrong variables (the Windows ones). The patch makes CMake recognize the UNIX style variables, see here for an example regarding libtiff.


Top
 Profile  
 
PostPosted: Wed, 2016-07-06, 20:00 
Offline

Joined: Wed, 2015-09-02, 09:24
Posts: 34
Well, still fail to work with the following
TIFF_INCLUDE_DIR=$(PATH_INSTALL)/include
TIFF_LIBRARY=$(PATH_INSTALL)/lib
TIFF_LIBRARIES=libtiff.a (I have also tried "tiff", "$(TIFF_LIBRARY)/libtiff.a")
Just about to retry with cmake on command line. Might there be any difference with the gui...


Top
 Profile  
 
PostPosted: Thu, 2016-07-07, 10:27 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Mon, 2014-03-03, 09:51
Posts: 231
Location: Oldenburg, Germany
As far as I know, you'll have to set TIFF_LIBRARY to $(PATH_INSTALL)/lib/libtiff.a.
Also, just to be sure, you still need to enable DCMTK_WITH_TIFF.

This is what my FindTIFF.cmake does:
Code:
  set(TIFF_LIBRARIES ${TIFF_LIBRARY})
  set(TIFF_INCLUDE_DIRS "${TIFF_INCLUDE_DIR}")

  if(NOT TARGET TIFF::TIFF)
    add_library(TIFF::TIFF UNKNOWN IMPORTED)
    if(TIFF_INCLUDE_DIRS)
      set_target_properties(TIFF::TIFF PROPERTIES
        INTERFACE_INCLUDE_DIRECTORIES "${TIFF_INCLUDE_DIRS}")
    endif()
    if(EXISTS "${TIFF_LIBRARY}")
      set_target_properties(TIFF::TIFF PROPERTIES
        IMPORTED_LINK_INTERFACE_LANGUAGES "C"
        IMPORTED_LOCATION "${TIFF_LIBRARY}")
    endif()


Top
 Profile  
 
PostPosted: Mon, 2016-07-11, 12:45 
Offline

Joined: Wed, 2015-09-02, 09:24
Posts: 34
Hi Jan,
thanks for the instructions! I have defined the variables exactly the same way as they are used in 3rdparty.make, but there's still some problem, which is quite strange to me. The reason I am linking external libs is mainly for libiconv, which I guess would allow me to call e.g. DcmFileFormat.loadFile() using file names/paths containing Unicode characters. Since cmake is somehow stuck at this step, probable writing a wrapper function with libiconv and then use the wrapper to convert the characters before I make the call would be easier... keep trying...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 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:  
Powered by phpBB® Forum Software © phpBB Group