Linking with static dcmdata/ofst lib from a .Net application

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Prash
Posts: 4
Joined: Thu, 2007-07-19, 18:16

Linking with static dcmdata/ofst lib from a .Net application

#1 Post by Prash »

Hi,

I recently attempted to build a simple forms application in Visual
Studio 2005 (Express) C++ edition. I built dcmtk package myself, as a
collection of static C++ libs. I then link with these libs from the
managed C++ forms application. Everything compiles fine, links great.
But there is a runtime access violation thrown as soon as the first
const is declared in a dcmtk file:

const OFConditionConst ECC_Normal( 0, 0, OF_ok,
"Normal");

I suspect it is because of mixing of unmanaged and managed C++ code. I did see similar posting earlier in the forum, relating to similar problems; but none of them discussed specific remedies.

If you have any expertise in this, please share.

FYI:

[1] All projects are built with /clr option and multithreaded dll
support, except dcmtk: multithreaded dll, but no clr. It wouldnt link
properly if built with /clr option.

[2] The application runs fine in release build, the access violation is in debug build.


Pixel.To.Life
[science.medical.imaging: http://groups.google.com/group/medicalimagingscience]
Last edited by Prash on Mon, 2011-02-14, 18:20, edited 3 times in total.

Prash
Posts: 4
Joined: Thu, 2007-07-19, 18:16

Re: using static dcmtk libs with managed forms application

#2 Post by Prash »

Ok I found the fix. Apparently this is a known issue in VC2005 express
edition, so when using a static constructor in unmanaged code with a
managed forms application, the entry point of the managed app should
not be 'main'. Here is the link to the angelic description (I tried,
works like magic:-)

http://www.thescripts.com/forum/thread642179.html


Another reason I dont like Microsoft - they market more than they
perfect their products!


Thanks all anyways,


Pixel.to.life.
Last edited by Prash on Mon, 2011-02-14, 18:20, edited 3 times in total.

Michael Onken
DCMTK Developer
Posts: 2055
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#3 Post by Michael Onken »

Hi Prash,

thanks for sharing your solution :)

Did you already take a look at the clearcanvas project who built a NET wrapper around parts of DCMTK? I am not sure whether this is of any interest for you but maybe it could be interesting for the future.

Regards,
Michael

Prash
Posts: 4
Joined: Thu, 2007-07-19, 18:16

#4 Post by Prash »

Thank you Michael. :)

For now, I am only mending a small hobby project, mostly to learn as I go. I will definitely keep ClearCanvas in mind.

Regards,

Prash

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Baidu [Spider], Google [Bot] and 0 guests