static lib compiled with /MD option problem

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
sguox002
Posts: 4
Joined: Fri, 2018-03-09, 08:47

static lib compiled with /MD option problem

#1 Post by sguox002 »

Hello, since I cannot get dcmtk3.6.3 working under a single dll and I have to go back to static library. I have to use /MD option since my project all compiled under /MD.
I had a test program which works under debug+debug lib, release+release lib. However it does not work under any other combinations. It just crashes when there is any dynamic memory allocation in the library causing heap corruption.
My problem is: I have to use dcmtk in my application with _ITERATOR_DEBUG_LEVEL=0 (some of my dll modules have to be run under release mode to keep performance). This drives me to use release version dcmtk library to work with my application. However, it crashes the same.

For example, the storescu will crash:
if (OFStandard::fileExists(currentFilename)) when the OFFilename destructor is called. The obj is constructed using strdup and destructed using free.
According to research, this kind of error might be due to different version of CRT.

Anybody has any clue on this?

J. Riesmeier
DCMTK Developer
Posts: 2503
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: static lib compiled with /MD option problem

#2 Post by J. Riesmeier »

You should first try to compile the DCMTK with CMake option DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS disabled (set to "OFF"). This should set the code generation option of Visual Studio to /MD.

sguox002
Posts: 4
Joined: Fri, 2018-03-09, 08:47

Re: static lib compiled with /MD option problem

#3 Post by sguox002 »

Yes, I generate the dcmtk library with /MD exactly by the way you mentioned

J. Riesmeier
DCMTK Developer
Posts: 2503
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: static lib compiled with /MD option problem

#4 Post by J. Riesmeier »

I personally never used _ITERATOR_DEBUG_LEVEL=0 but, maybe, you also need to compile the DCMTK with this setting?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 1 guest