Compilation of DCMTK-based program fails with LNK2019 [MSVC]

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
daviddavid
Posts: 4
Joined: Mon, 2005-05-16, 19:06

Compilation of DCMTK-based program fails with LNK2019 [MSVC]

#1 Post by daviddavid »

Hi,
I am using dcmimgle library. According to the library dependency, the libraries are included as: ofstd.lib, dcmdata.lib, dcmimgle.lib. And when compiling the program, I got the following errors. What is the cause of this error? Thank you a lot for the help.


Here is the error message:
--------------------------------------------------------------
testdicom error LNK2019: unresolved external symbol _Netbios@4 referenced in function "unsigned char * __cdecl getMACAddress(unsigned char * const)" (?getMACAddress@@YAPAEQAE@Z)
testdicom error LNK2019: unresolved external symbol _inflateInit2_ referenced in function "public: __thiscall DcmZLibInputFilter::DcmZLibInputFilter(void)" (??0DcmZLibInputFilter@@QAE@XZ)
testdicom error LNK2019: unresolved external symbol _inflateInit_ referenced in function "public: __thiscall DcmZLibInputFilter::DcmZLibInputFilter(void)" (??0DcmZLibInputFilter@@QAE@XZ)
testdicom error LNK2019: unresolved external symbol _inflateEnd referenced in function "public: virtual __thiscall DcmZLibInputFilter::~DcmZLibInputFilter(void)" (??1DcmZLibInputFilter@@UAE@XZ)
testdicom error LNK2019: unresolved external symbol _inflate referenced in function "private: unsigned long __thiscall DcmZLibInputFilter::decompress(void const *,unsigned long)" (?decompress@DcmZLibInputFilter@@AAEKPBXK@Z)
testdicom error LNK2019: unresolved external symbol _deflateInit2_ referenced in function "public: __thiscall DcmZLibOutputFilter::DcmZLibOutputFilter(void)" (??0DcmZLibOutputFilter@@QAE@XZ)
testdicom error LNK2019: unresolved external symbol _deflateEnd referenced in function "public: virtual __thiscall DcmZLibOutputFilter::~DcmZLibOutputFilter(void)" (??1DcmZLibOutputFilter@@UAE@XZ)
testdicom error LNK2019: unresolved external symbol _deflate referenced in function "private: unsigned long __thiscall DcmZLibOutputFilter::compress(void const *,unsigned long,bool)" (?compress@DcmZLibOutputFilter@@AAEKPBXK_N@Z)
testdicom fatal error LNK1120: 8 unresolved externals
-------------------------------------------------------

daviddavid
Posts: 4
Joined: Mon, 2005-05-16, 19:06

#2 Post by daviddavid »

Hi,

After linking in the zlib_d.lib library, the error message list was shortened. But I still have one error left. What else library I should link into the project to eliminate it? Thanks a lot. Here is the new error message:

---------------------------------
testdicom fatal error LNK1120: 1 unresolved externals
testdicom error LNK2019: unresolved external symbol _Netbios@4 referenced in function "unsigned char * __cdecl getMACAddress(unsigned char * const)" (?getMACAddress@@YAPAEQAE@Z)
testdicom warning LNK4098: defaultlib 'libcmtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
---------------------------------

daviddavid
Posts: 4
Joined: Mon, 2005-05-16, 19:06

#3 Post by daviddavid »

I finally figured this out. Thanks.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#4 Post by Jörg Riesmeier »

For all other readers, check FAQ #26 and #27.

trisch
Posts: 6
Joined: Mon, 2010-05-31, 18:06

#5 Post by trisch »

Hi all,

I have read articles here and FAQ 26 adn 27, but still founded no answers.

In my app for 32 bits everything is ok, but when I compiled dcmtk to 64bit with /MDd and then try to compile my code - it brings errors:

2>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol WSACleanup referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ)
2>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol gethostbyname referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ)
2>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol gethostname referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ)
2>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol WSAStartup referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ)
2>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol Netbios referenced in function "unsigned char * __cdecl getMACAddress(unsigned char * const)" (?getMACAddress@@YAPEAEQEAE@Z)

order of libs is:
"D:\Program Files\Microsoft Visual Studio\VC98\Lib\NETAPI32.LIB"
"D:\Program Files\Microsoft Visual Studio\VC98\Lib\WSOCK32.LIB"
\include\dcmtk-3.5.4-win64-i386\lib\ofstd.lib
\include\dcmtk-3.5.4-win64-i386\lib\dcmdata.lib
\include\dcmtk-3.5.4-win64-i386\lib\dcmimgle.lib

I've even tried another order(reverse, in case if I've wrong understood FAQ 27) - still the same.

Please, can anyone help me - what I have done wrong or maybe here is some tricks for 64bit compilation?

Chung-Yueh Lien
Posts: 61
Joined: Wed, 2010-05-19, 09:27
Location: Taipei, Taiwan

#6 Post by Chung-Yueh Lien »

Hi, trisch
trisch wrote:Hi all,
In my app for 32 bits everything is ok, but when I compiled dcmtk to 64bit with /MDd and then try to compile my code - it brings errors:
Did you ever convert the supported libraries to x64 version ?
it has to convert 64x not only in CMake but also in supported libraries such as zlib, openssll, etc.

trisch
Posts: 6
Joined: Mon, 2010-05-31, 18:06

#7 Post by trisch »

Chung-Yueh Lien wrote: Did you ever convert the supported libraries to x64 version ?
it has to convert 64x not only in CMake but also in supported libraries such as zlib, openssll, etc.
Hi,

Thanks for your reply. I don't use supported libraries for dcmtk, but btw I have found error - before these libs (dcmimgle,dcmdata,ofstd,NETAPI32,WSOCK32) were standart libraries, which CMake-GUI has included, I don't remember which exactly. When I removed them - build was successfully.

mattywix
Posts: 15
Joined: Wed, 2011-03-30, 15:31

#8 Post by mattywix »

The practical answer is to add the 64 bit SDK library path to your build as the first directory:

So your link path is something like this:
C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64;..\zlib-1.2.5-cmake\lib;..\dcmtk-3.6.0-cmake\lib;%(AdditionalLibraryDirectories)

Then make sure as per the FAQs suggested, that you have the following libraries listed in the front of the list of additional dependencies:
zlib_o.lib;netapi32.lib;wsock32.lib;WS2_32.Lib

Then after those ones put all the other stuff you already had.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest