Compiling errors with support libraries for windows

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
kattabomane
Posts: 43
Joined: Tue, 2005-02-01, 22:53

Compiling errors with support libraries for windows

#1 Post by kattabomane » Tue, 2018-08-21, 04:42

Hello,

I have several compiling issues (mainly related to libxml2, libtiff, libpng) when compiling with the following mode :
- Windows 10 x64 (1803)
- Visual studio 15.8.1
- CMake 3.12.1
- DCMTK 3.6.3
- dcmtk-3.6.3-win64-support_MD-msvc-15.0
- building in x64
- /MD

I am building non shared lib with default cmake options and checked options to support libpng, libtiff, openssl, zlib, libxml2, iconv.

There are 14 projects that does not build :
dcmp2pgm, dcmprscp, dcml2pnm, dcmj2pnm, dcmprscu, dsr2html, dsrdump...

The errors are :
12>OLDNAMES.lib(close.obi) : warning LNK4049: locally defined symbol _close imported
12>OLDNAMES.lib(read.obi) : warning LNK4049: locally defined symbol _read imported
12>OLDNAMES.lib(write.obi) : warning LNK4049: locally defined symbol _write imported
12>OLDNAMES.lib(getcwd.obi) : warning LNK4049: locally defined symbol _getcwd imported
12>OLDNAMES.lib(open.obi) : warning LNK4049: locally defined symbol _open imported
12>libxml2_o.lib(xmlIO.obj) : error LNK2019: unresolved external symbol __imp_close referenced in function xmlFdClose
12>libxml2_o.lib(catalog.obj) : error LNK2001: unresolved external symbol __imp_close
12>libxml2_o.lib(nanohttp.obj) : error LNK2001: unresolved external symbol __imp_close
12>OLDNAMES.lib(close.obi) : error LNK2001: unresolved external symbol __imp_close
12>libxml2_o.lib(xmlIO.obj) : error LNK2019: unresolved external symbol __imp_read referenced in function xmlFdRead
12>libxml2_o.lib(catalog.obj) : error LNK2001: unresolved external symbol __imp_read
12>OLDNAMES.lib(read.obi) : error LNK2001: unresolved external symbol __imp_read
12>libxml2_o.lib(xmlIO.obj) : error LNK2019: unresolved external symbol __imp_write referenced in function xmlFdWrite
12>libxml2_o.lib(nanohttp.obj) : error LNK2001: unresolved external symbol __imp_write
12>OLDNAMES.lib(write.obi) : error LNK2001: unresolved external symbol __imp_write
12>libxml2_o.lib(xmlIO.obj) : error LNK2019: unresolved external symbol __imp_getcwd referenced in function xmlParserGetDirectory
12>OLDNAMES.lib(getcwd.obi) : error LNK2001: unresolved external symbol __imp_getcwd
12>libxml2_o.lib(catalog.obj) : error LNK2019: unresolved external symbol __imp_open referenced in function xmlLoadFileContent
12>libxml2_o.lib(nanohttp.obj) : error LNK2001: unresolved external symbol __imp_open
12>OLDNAMES.lib(open.obi) : error LNK2001: unresolved external symbol __imp_open
...
Also lots of warnings :
>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
4>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
3>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
4>libxml2_o.lib(xmlreader.obj) : warning LNK4049: locally defined symbol __acrt_iob_func imported
3>libxml2_o.lib(xmlreader.obj) : warning LNK4049: locally defined symbol __acrt_iob_func imported
2>libtiff_o.lib(tif_close.obj) : warning LNK4217: locally defined symbol strncmp imported in function TIFFCleanup
4>libxml2_o.lib(debugXML.obj) : warning LNK4049: locally defined symbol __acrt_iob_func imported
4>libxml2_o.lib(xmlIO.obj) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function xmlFileRead
4>libxml2_o.lib(relaxng.obj) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function xmlRelaxNGCompile
4>libxml2_o.lib(xpath.obj) : warning LNK4049: locally defined symbol __acrt_iob_func imported
4>libxml2_o.lib(xmlregexp.obj) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function xmlRegCheckCharacterRange
4>libxml2_o.lib(tree.obj) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function xmlBufferDump
4>libxml2_o.lib(error.obj) : warning LNK4049: locally defined symbol __acrt_iob_func imported
4>libxml2_o.lib(parserInternals.obj) : warning LNK4049: locally defined symbol __acrt_iob_func imported
4>libxml2_o.lib(buf.obj) : warning LNK4049: locally defined symbol __acrt_iob_func imported
4>libxml2_o.lib(tree.obj) : warning LNK4217: locally defined symbol fwrite imported in function xmlBufferDump
4>libxml2_o.lib(buf.obj) : warning LNK4049: locally defined symbol fwrite imported
4>libxml2_o.lib(xmlIO.obj) : warning LNK4217: locally defined symbol fwrite imported in function xmlFileWrite
4>iconv_o.lib(localcharset.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(HTMLtree.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(nanohttp.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(nanoftp.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(debugXML.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(relaxng.obj) : warning LNK4217: locally defined symbol __stdio_common_vsprintf imported in function xmlRelaxNGCompile
4>libxml2_o.lib(xpath.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(xmlregexp.obj) : warning LNK4217: locally defined symbol __stdio_common_vsprintf imported in function xmlRegCheckCharacterRange
4>libxml2_o.lib(xmlreader.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(uri.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(HTMLparser.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(catalog.obj) : warning LNK4217: locally defined symbol __stdio_common_vsprintf imported in function xmlDumpXMLCatalogNode
4>libxml2_o.lib(xmlschemastypes.obj) : warning LNK4217: locally defined symbol __stdio_common_vsprintf imported in function xmlSchemaGetBuiltInType
4>libxml2_o.lib(parser.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(parserInternals.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(xmlschemas.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(entities.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(tree.obj) : warning LNK4217: locally defined symbol __stdio_common_vsprintf imported in function snprintf
4>libxml2_o.lib(xmlstring.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(error.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(encoding.obj) : warning LNK4049: locally defined symbol __stdio_common_vsprintf imported
4>libxml2_o.lib(xmlschemastypes.obj) : warning LNK4217: locally defined symbol memmove imported in function xmlSchemaGetBuiltInType
4>libxml2_o.lib(xpath.obj) : warning LNK4049: locally defined symbol memmove imported
4>libxml2_o.lib(nanohttp.obj) : warning LNK4049: locally defined symbol memmove imported
4>libxml2_o.lib(nanoftp.obj) : warning LNK4049: locally defined symbol memmove imported
4>libxml2_o.lib(tree.obj) : warning LNK4217: locally defined symbol memmove imported in function xmlBufferAdd
4>libxml2_o.lib(encoding.obj) : warning LNK4049: locally defined symbol memmove imported
3>libxml2_o.lib(debugXML.obj) : warning LNK4049: locally defined symbol __acrt_iob_func imported
3>libxml2_o.lib(xmlIO.obj) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function xmlFileRead
3>libxml2_o.lib(relaxng.obj) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function xmlRelaxNGCompile
3>libxml2_o.lib(xpath.obj) : warning LNK4049: locally defined symbol __acrt_iob_func imported
3>libxml2_o.lib(xmlregexp.obj) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function xmlRegCheckCharacterRange
3>libxml2_o.lib(tree.obj) : warning LNK4217: locally defined symbol __acrt_iob_func imported in function xmlBufferDump
3>libxml2_o.lib(error.obj) : warning LNK4049: locally defined symbol __acrt_iob_func imported
3>libxml2_o.lib(parserInternals.obj) : warning LNK4049: locally defined symbol __acrt_iob_func imported
3>libxml2_o.lib(buf.obj) : warning LNK4049: locally defined symbol __acrt_iob_func imported
3>libxml2_o.lib(tree.obj) : warning LNK4217: locally defined symbol fwrite imported in function xmlBufferDump
...
I saw one post related to the following "error LNK2001: unresolved external symbol __imp_close..." but their problem is solved by building shared libs.

Could you please give me some hints of what is going wrong ?

Thanks

K.

kattabomane
Posts: 43
Joined: Tue, 2005-02-01, 22:53

Re: Compiling errors with support libraries for windows

#2 Post by kattabomane » Tue, 2018-08-21, 05:31

Hello,

i figured out some mixture between /MD and /MT.

Using Cmake i have the following :

CMAKE_CXX_FLAGS_DEBUG : /MDd /Zi /Ob0 /Od /RTC1
CMAKE_CXX_FLAGS_RELEASE : /MD /O2 /Ob2 /DNDEBUG
CMAKE_C_FLAGS_DEBUG : /MDd /Zi /Ob0 /Od /RTC1
CMAKE_C_FLAGS_RELEASE : /MD /O2 /Ob2 /DNDEBUG

But the projects in Visual studio have :

Multi-threaded Debug (/MTd)

How is this possible ?
Any bug ?

Thanks for your help.
K.

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

Re: Compiling errors with support libraries for windows

#3 Post by Jan Schlamelcher » Mon, 2018-09-03, 08:36

DCMTK overwrites CMAKE_CXX_FLAGS etc. for Visual Studio for various reasons. To switch from /MT to /MD etc. please set BUILD_SHARED_LIBS=ON instead.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests