External libs with mingw
Moderator: Moderator Team
External libs with mingw
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!
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!
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: External libs with mingw
Sorry, I wanted to have commited this some time ago, but I did not come to do serious testing with it:
This patch effectively changes the used find_package mechanism so that MinGW is handled the same as UNIX, which always worked for me.
Code: Select all
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)
Re: External libs with mingw
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
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
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: External libs with mingw
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.
Re: External libs with mingw
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...
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...
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: External libs with mingw
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:
Also, just to be sure, you still need to enable DCMTK_WITH_TIFF.
This is what my FindTIFF.cmake does:
Code: Select all
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()
Re: External libs with mingw
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...
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...
Who is online
Users browsing this forum: Bing [Bot] and 1 guest