Link error when building on Windows 10 + Visual Studio 2015

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
zzzhhh
Posts: 12
Joined: Tue, 2018-07-03, 11:08

Link error when building on Windows 10 + Visual Studio 2015

#1 Post by zzzhhh »

I am trying to build DCMTK using provided 3rd party pre-compiled binaries on Windows 10 + Visual Studio 2015, but there are always errors.

Environment:
- Windows 10 version 1803
- Visual Studio 2015 Update 3
- CMake 3.11.4

Building configurations:
- The DCMTK source package is dcmtk-3.6.3.tar.gz downloaded from https://dicom.offis.de/dcmtk
- The 3rd party pre-compiled binaries is dcmtk-3.6.3-win64-support_MD-msvc-14.0.zip downloaded from ftp://dicom.offis.de/pub/dicom/offis/so ... 3/support/. It is uncompressed under the DCMTK root directory.
- The cmake command line is:

Code: Select all

cmake -DCMAKE_CONFIGURATION_TYPES=Release -DCMAKE_INSTALL_PREFIX=C:\...\dcmtk-3.6.3\install_ -DDCMTK_ENABLE_STL=ON -DDCMTK_ENABLE_CXX11:BOOL=ON -DDCMTK_WITH_DOXYGEN=1 -DDCMTK_WITH_XML=ON -DWITH_LIBXMLINC=C:\...\dcmtk-3.6.3\dcmtk-3.6.3-win64-support_MD-msvc-14.0\libxml2-2.9.7 -DDCMTK_WITH_PNG=ON -DWITH_LIBPNGINC=C:\...\dcmtk-3.6.3\dcmtk-3.6.3-win64-support_MD-msvc-14.0\libpng-1.6.34 -DDCMTK_WITH_TIFF=ON -DWITH_LIBTIFFINC=C:\...\dcmtk-3.6.3\dcmtk-3.6.3-win64-support_MD-msvc-14.0\libtiff-4.0.9 -DDCMTK_WITH_ZLIB=ON -DWITH_ZLIBINC=C:\...\dcmtk-3.6.3\dcmtk-3.6.3-win64-support_MD-msvc-14.0\zlib-1.2.11 -DDCMTK_WITH_ICONV=ON -DWITH_LIBICONVINC=C:\...\dcmtk-3.6.3\dcmtk-3.6.3-win64-support_MD-msvc-14.0\libiconv-1.15 -DDCMTK_WITH_OPENSSL=ON -DWITH_OPENSSLINC=C:\...\dcmtk-3.6.3\dcmtk-3.6.3-win64-support_MD-msvc-14.0\openssl-1.1.0g -G"Visual Studio 14 2015 Win64" ..
- Open the generated DCMTK.sln in Visual Studio 2015 and build ALL_BUILD.

Errors (only a small part of them):
38>libtiff_o.lib(tif_unix.obj) : error LNK2019: unresolved external symbol __imp_open referenced in function TIFFOpen
38>OLDNAMES.lib(open.obi) : error LNK2001: unresolved external symbol __imp_open
38>libtiff_o.lib(tif_unix.obj) : error LNK2019: unresolved external symbol __imp_read referenced in function _tiffReadProc
38>OLDNAMES.lib(read.obi) : error LNK2001: unresolved external symbol __imp_read
38>libtiff_o.lib(tif_unix.obj) : error LNK2019: unresolved external symbol __imp_write referenced in function _tiffWriteProc
38>OLDNAMES.lib(write.obi) : error LNK2001: unresolved external symbol __imp_write
38>libtiff_o.lib(tif_dirinfo.obj) : error LNK2019: unresolved external symbol __imp_bsearch referenced in function TIFFFindField
38>libpng_o.lib(pngget.obj) : error LNK2019: unresolved external symbol __imp_atof referenced in function png_get_sCAL
38>C:\...\dcmtk-3.6.3\build\bin\Release\dcmj2pnm.exe : fatal error LNK1120: 5 unresolved externals
I checked libtiff_o.lib in the pre-built package using dumpbin, and found that all the above unresolved functions reside in it. My building steps should be canonical so I can see nowhere that could introduce problems. The build is clean so there is no cache residues that may cause any issue. I am at my wit's end so I ask here what the matter is and how to fix the linking problem. Thank you.

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

Re: Link error when building on Windows 10 + Visual Studio 2

#2 Post by Jan Schlamelcher »


zzzhhh
Posts: 12
Joined: Tue, 2018-07-03, 11:08

Re: Link error when building on Windows 10 + Visual Studio 2

#3 Post by zzzhhh »

Jan Schlamelcher wrote:Is it this one: https://forum.dcmtk.org/viewtopic.php?f=4&t=35
No, they are not the same question. DCMTK by default use /MD to generate dll, right? I tried to set it using -DBUILD_SHARED_LIBS=ON but it's not used in cmake.
Last edited by zzzhhh on Tue, 2018-07-03, 16:48, edited 1 time in total.

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

Re: Link error when building on Windows 10 + Visual Studio 2

#4 Post by Jan Schlamelcher »

I think the default is MT and -DBUILD_SHARED_LIBS=ON should change it to MD, but I did not see -DBUILD_SHARED_LIBS=ON in your CMake command line and assumed the problem originated from MT/MD incompatibility.

zzzhhh
Posts: 12
Joined: Tue, 2018-07-03, 11:08

Re: Link error when building on Windows 10 + Visual Studio 2

#5 Post by zzzhhh »

Jan Schlamelcher wrote:I think the default is MT and -DBUILD_SHARED_LIBS=ON should change it to MD, but I did not see -DBUILD_SHARED_LIBS=ON in your CMake command line and assumed the problem originated from MT/MD incompatibility.
You are so cool! It works after I add -DBUILD_SHARED_LIBS=ON. I remember that once cmake said at the end that BUILD_SHARED_LIBS is not used so I didn't add it since then. Now everything is working, including the test! Thank you.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest