Documention to develop application linking to DCMTK libraries and including required DCMTK files

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
sas
Posts: 7
Joined: Tue, 2005-01-04, 17:38

Documention to develop application linking to DCMTK libraries and including required DCMTK files

#1 Post by sas »

Hi,

I am looking for some documentation which describes in details how we can link to DCMTK libraries and develop our own executable. Some documentation that mentions the include files that needs to be included in my application and what all libraries I need to link to for developing a GUI based Query/ Retrieve tool for example.
Does such a documentation exist somewhere?

markw
Posts: 84
Joined: Mon, 2005-01-17, 01:08

#2 Post by markw »

Hi sas,

I just downloaded this package last night and in the FAQ there is a question titled "Where is the rest of the documentation?" The answer was that as of version 3.5 there are a few simple examples in the doc folders of each sub folder, but I am running into the same exact problem - what headers do I need and what libraries should I link to?

I have attempted this as a test:
[code]
int main()
{
DicomImage *image = new DicomImage("C:\\test.dcm");
}
[/code]
But I received a ton of link errors naturally. I have one more linking error:

LNK2019: unresolved external symbol _Netbios@4 referenced in function "unsigned char * __cdecl getMACAddress(unsigned char * const)

Does anyone know which lib this is in, I cannot find it!

Thanks,
Mark

wrgben
Posts: 20
Joined: Thu, 2005-01-06, 10:53

#3 Post by wrgben »

Mark,

You need to link against netapi32.lib and wsock32.lib to resolve these errors.

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 »

See also FAQ #27.

wrgben
Posts: 20
Joined: Thu, 2005-01-06, 10:53

#5 Post by wrgben »

Danke Jörg, I *knew* there was a FAQ entry for that somewhere!

markw
Posts: 84
Joined: Mon, 2005-01-17, 01:08

#6 Post by markw »

Thanks everyone, that got me going with the toolkit!

(I was missing netapi32.lib as you said wrgben)

sas
Posts: 7
Joined: Tue, 2005-01-04, 17:38

#7 Post by sas »

Hi,

I still have problems in linking my application which provides the same fuctionality as findscu application does, and also has a GUI to it. I am developing my application on Windows XP platform and have linked to the following libraries:
dcmdata.lib ofstd.lib netapi32.lib wsock32.lib dcmnet.lib
in the order mentioned.

I still get the following linking error, anyone knows why:
libcpmtd.lib(xmutex.obj) : error LNK2005: "public: void __thiscall std::_Mutex::_Lock(void)" (?_Lock@_Mutex@std@@QAEXXZ) already defined in ......
libcpmtd.lib(xmutex.obj) : error LNK2005: "public: void __thiscall std::_Mutex::_Unlock(void)" (?_Unlock@_Mutex@std@@QAEXXZ) already defined in ..........
ofstd.lib(ofthread.obj) : error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall OFThread::start(void)" (?start@OFThread@@QAEHXZ)
ofstd.lib(ofthread.obj) : error LNK2019: unresolved external symbol __endthreadex referenced in function "protected: static void __cdecl OFThread::thread_exit(void)" (?thread_exit@OFThread@@KAXXZ)

sas
Posts: 7
Joined: Tue, 2005-01-04, 17:38

#8 Post by sas »

Hi,

This is in continuation with my previous post. While linking to the libraries, I have excluded the "LIBCMTD.lib" from the set of default libraries to be linked to, because of linking errors saying that many of the methods have been already defined in "LIBCD.lib".
If I include "LIBCMTD.lib" and exclude "LIBCD.lib", I get unresloved symbol "_errno".
I am comipling in Visual Studio .NET 2003.

Any help is highly appreciated.

Thanks,
sas

markw
Posts: 84
Joined: Mon, 2005-01-17, 01:08

#9 Post by markw »

Are you sure you compiled your GUI app and the dcmtk toolkit with the same runtime library, and use of MFC? Are you sure you're linking to the same release version of the compilation (ie: don't link you're release compiled GUI app to the debug compilation of dcmtk).

What is your configuration anyways?

sas
Posts: 7
Joined: Tue, 2005-01-04, 17:38

#10 Post by sas »

Hi,

I am trying to link the Debug version of my application to the Debug version of dcmtk. Any clues as to why I am getting linking errors as mentioned in my previous posts??
Congfiguration- Debug
Platform- Win32
Command line options as displayed when clicked at "Command Line" under "Linker" on the project property page:
/OUT:"Debug/tryDcmtk.exe" /INCREMENTAL /NOLOGO /LIBPATH:"..\dcmtk-3.5.3\dcmdata\libsrc\Debug" /LIBPATH:"..\dcmtk-3.5.3\ofstd\libsrc\Debug" /LIBPATH:"C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib" /LIBPATH:"..\dcmtk-3.5.3\dcmnet\libsrc\Debug" /NODEFAULTLIB:"LIBCD.lib" /DEBUG /PDB:"Debug/tryDcmtk.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86 dcmdata.lib ofstd.lib netapi32.lib wsock32.lib dcmnet.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "..\dcmtk-3.5.3\dcmdata\libsrc\Debug\dcmdata.lib" "..\dcmtk-3.5.3\ofstd\libsrc\Debug\ofstd.lib" "..\dcmtk-3.5.3\dcmnet\libsrc\Debug\dcmnet.lib"

Thomas Wilkens
DCMTK Developer
Posts: 117
Joined: Tue, 2004-11-02, 17:21
Location: Oldenburg, Germany
Contact:

#11 Post by Thomas Wilkens »

We dont have any experience with Visual Studio .NET 2003, I dont even have that compiler on my machine since we are still using MSVC6 for DCMTK. But the problem is very very probably located in the "runtime library" settings for both projects: please pay attention to (what in MSVC6 is labeled) the "Code generation" -> "Runtime library" combobox in the project settings. You have to pick the same setting here for both projects, DCMTK and your GUI.

For DCMTK, the default setting in this combobox is "Multithreaded" (not "Single threaded" or "Multithreaded DLL" or any of the other options), so for your GUI, the same has to be applied. As I dont have Visual Studio .NET 2003 available here, I cannot tell you where you can find that setting, I am sorry. Maybe somebody else can tell you.

sas
Posts: 7
Joined: Tue, 2005-01-04, 17:38

#12 Post by sas »

Hi Thomas,
Thanks a lot. Your suggestion was really helpful. Now I am able to link my application to dcmtk :-)

tcashen
Posts: 2
Joined: Mon, 2005-03-07, 06:44

Linking to DCMTK for MATLAB mex Files

#13 Post by tcashen »

The MATLAB mathematical software has built-in supported for the DICOM format, but since all the code is written in the interpreted MATLAB language, it is unbearably slow. I'd like to use DCMTK and MATLAB's ability to use compiled C code in "mex" files in order to speed up the reading of DICOM files. ("mex" files are simply .dll's that MATLAB can call like a function.)

Anyway, I compiled the libraries necessary to use the DicomImage class (ofstd, dcmdata, and dcmimgle) and figured out that I had to additionally link to wsock32.lib and netapi32.lib based on linker errors. Even so, I still get the following linker error:

LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main

This error indicates to me that the compiler/linker thinks I'm trying to make a console or GUI application with a main() function required, instead of a .dll. Although I'm compiling the .dll within the MATLAB environment, I've set it to use the MSVStudio compiler. I've never had any problems like this in the past when making .dll's for MATLAB, so I'm wondering if the DCMTK needs to be specifically configured for use in .dll's rather than applications.

Any ideas? Thanks!

tcashen
Posts: 2
Joined: Mon, 2005-03-07, 06:44

#14 Post by tcashen »

I thought I'd set the compiler options to "Multithreaded DLL" (/MD) as FAQ #26 suggests, but apparently I must have not done it correctly the first time.

Anyway, I tried it again, and it worked!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest