iconv

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
gzhang
Posts: 50
Joined: Wed, 2015-09-02, 09:24

iconv

#1 Post by gzhang » Fri, 2018-06-01, 09:54

Hi,

I am wondering if anyone has succeeded in compiling v3.6.3 with "iconv" under mingw64 (windows) + CMake? Actually I never succeeded before (v3.6.0, .1, .2)

The iconv header and library file seem to be available within mingw64:
"C:\mingw64\x86_64-w64-mingw32\include\iconv.h"
"C:\mingw64\x86_64-w64-mingw32\lib\libiconv.a"

I have been trying to set LIBICONV_INCLUDE_DIR, LIBICONV_LIBRARY, LIBICONV_LIBDIR in different ways in CMake but they simply cannot be found:
Could NOT find LIBICONV (missing: LIBICONV_LIBRARY LIBICONV_INCLUDE_DIR)
Could NOT find LIBCHARSET (missing: LIBCHARSET_LIBRARY LIBCHARSET_INCLUDE_DIR)
Warning: ICONV support will be disabled because libiconv was not found. Correct LIBICONV_LIBDIR and LIBICONV_INCLUDE_DIR and re-enable DCMTK_WITH_ICONV.
Here is how the original dcmtk-3.6.3\CMake\FindICONV.cmake looks like:
INCLUDE(FindPackageHandleStandardArgs)
INCLUDE(dcmtkTryCompile)

# Look for the header file
FIND_PATH(LIBICONV_INCLUDE_DIR NAMES iconv.h)
MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR)

# Look for the library
SET(LIBICONV_LIBS iconv)
FIND_LIBRARY(LIBICONV_LIBRARY NAMES ${LIBICONV_LIBS})
MARK_AS_ADVANCED(LIBICONV_LIBRARY)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBICONV REQUIRED_VARS LIBICONV_LIBRARY LIBICONV_INCLUDE_DIR)

# Copy the result to output variables
IF(LIBICONV_FOUND)
SET(LIBICONV_LIBRARIES ${LIBICONV_LIBRARY})
SET(LIBICONV_INCLUDE_DIRS ${LIBICONV_INCLUDE_DIR})
ELSE(LIBICONV_FOUND)
SET(LIBICONV_LIBS)
SET(LIBICONV_LIBRARY)
SET(LIBICONV_LIBRARIES)
SET(LIBICONV_INCLUDE_DIR)
SET(LIBICONV_INCLUDE_DIRS)
ENDIF(LIBICONV_FOUND)
Anyone mind sharing with your successful settings? Thanks!

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

Re: iconv

#2 Post by Jan Schlamelcher » Fri, 2018-06-01, 11:19

Dear gzhang,

I just looked it up, our nightly MinGW builds also don't use the iconv library (says the overview). The one build I specifically looked at said

Code: Select all

-- Info: Building DCMTK without character set conversion support
We have CMake based scripts for creating the support libraries you can download from our website (that we are planing to make available once we finish documenting them), but they currently only address Visual Studio. I think it would be really usefull to also test character set conversion on the MinGW builds, but I don't know when someone will find the time to add support for that.

Regarding the iconv library already included in your MinGW "distribution", it seems to lack the charset library DCMTK needs, which is normally part of a full libiconv installation, so this seems to be some kind of minimalistic version. Maybe have a look at MSYS2? They made a very good choice (if you ask me as an Arch Linux user) to integrate 'pacman' into MSYS2, so you can possibly simply do a 'pacman -S libiconv' and be done with it.

gzhang
Posts: 50
Joined: Wed, 2015-09-02, 09:24

Re: iconv

#3 Post by gzhang » Fri, 2018-06-01, 13:00

Hi Jan,

Thanks for the hints! I just did a quick test with a new 'iconv' and 'charset' in Msys2.

Since 'Msys2' already has an 'iconv.exe' included in its 'bin', the command 'pacman -S libiconv' was not able to help me find new files of 'libiconv.a', etc. So, I downloaded the source 'libiconv-1.15' and remade it in Msys2. The following files are installed:
/usr/include/iconv.h
/usr/include/libcharset.h
/usr/lib/iconv.a
/usr/lib/libcharset.a

Compared to those included in mingw64, these newly installed files are larger in size, probably due to version change.

Cleaning up 'dcmtk-3.6.3-build' and reconfiguring it in CMake, with 'LIBICONV_LIBDIR', 'LIBICONV_INCLUDE_DIR', etc, set properly, same error was reported unfortunately:
Could NOT find LIBICONV (missing: LIBICONV_LIBRARY LIBICONV_INCLUDE_DIR)
Could NOT find LIBCHARSET (missing: LIBCHARSET_LIBRARY LIBCHARSET_INCLUDE_DIR)
Warning: ICONV support will be disabled because libiconv was not found. Correct LIBICONV_LIBDIR and LIBICONV_INCLUDE_DIR and re-enable DCMTK_WITH_ICONV.
I guess there has to be something wrong with 'FindICONV.cmake'.

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

Re: iconv

#4 Post by Jan Schlamelcher » Fri, 2018-06-01, 14:11

Thats good to know, so, if MSYS2 already comes with a full libiconv, we should also have it on our nightly build server. I'll ask the one that manages it to incorporate the libiconv into the MinGW builds. He'll be back next week, let's see what he manages to do.

gzhang
Posts: 50
Joined: Wed, 2015-09-02, 09:24

Re: iconv

#5 Post by gzhang » Fri, 2018-06-01, 14:16

Thanks!
Msys2 includes 'iconv.exe' as a 'bin', but not as 'lib', which was why I made it from the source separately.

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

Re: iconv

#6 Post by Jan Schlamelcher » Tue, 2018-06-19, 09:10

We've made progress... our CI guy managed to build DCMTK with libiconv using MSYS2 (even only using the iconv implementation shipped with MSYS). The bad news is that some modifications to DCMTK were necessary. He did that in a hackish way that should never be seen in public. A general solution is being worked on, which can be tracked here.

gzhang
Posts: 50
Joined: Wed, 2015-09-02, 09:24

Re: iconv

#7 Post by gzhang » Tue, 2018-06-19, 09:12

Thanks Jan for the feedback! That would be very nice news :-)

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

Re: iconv

#8 Post by Jan Schlamelcher » Tue, 2018-07-10, 11:29

It's live, see commits 0178bca9 and a9561f36.

gzhang
Posts: 50
Joined: Wed, 2015-09-02, 09:24

Re: iconv

#9 Post by gzhang » Tue, 2018-07-10, 14:00

Thanks!
One question: does it have to be a "Msys makefile" with CMake? or a "MinGW makefile" also fine? If I understood correctly, Msys2 was only used to build iconv, nothing else, right?

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

Re: iconv

#10 Post by Jan Schlamelcher » Tue, 2018-07-10, 15:25

MinGW Makefiles will perhaps also work, but we only ever used MSYS Makefiles (I think), so it is untested.

gzhang
Posts: 50
Joined: Wed, 2015-09-02, 09:24

Re: iconv

#11 Post by gzhang » Wed, 2018-07-11, 13:23

Hi,
Would it be possible to let me see which CMake variables need to be set?
Not all of them seem to work as reported in "CMakeCache.txt":
//iconv include directory
Iconv_INCLUDE_DIR:PATH=Iconv_INCLUDE_DIR-NOTFOUND

//iconv library (potentially the C library)
Iconv_LIBRARY:FILEPATH=Iconv_LIBRARY-NOTFOUND

//Path to a file.
LIBCHARSET_INCLUDE_DIR:PATH=LIBCHARSET_INCLUDE_DIR-NOTFOUND

//Path to a library.
LIBCHARSET_LIBRARY:FILEPATH=LIBCHARSET_LIBRARY-NOTFOUND

LIBICONV_INCLUDE_DIR:PATH=C:/msys2/usr/local/include

LIBICONV_LIBDIR:PATH=C:/msys2/usr/local/lib
Only the last 2 does, and CMake complains about 'charset' now.

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

Re: iconv

#12 Post by Jan Schlamelcher » Wed, 2018-07-11, 13:46

Should be as specified here regarding the Iconv library and whatever is appropriate for the charset library. I'll ask Nikolas to provide some notes about how he tested his commits under MinGW.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest