Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# wrapper for DCMTK library using SWIG

I want to create C# wrapper for DCMTK library (which is written in C++) using SWIG. I have full source code of DCMTK, but I have one problem I can't solve...

My script for SWIG looks like this:

#ifndef WRAPPER_SWIG_I
# define WRAPPER_SWIG_I
%{ 
%}

%include "include/dcmtk/dcmjpeg/ddpiimpl.h"
%include "include/dcmtk/dcmjpeg/dipijpeg.h"
%include "include/dcmtk/dcmjpeg/djcodecd.h"
#endif

Then I run SWIG from command line:

swig -includeall -Wall -c++ -csharp -outdir $(SolutionDir)\dcmjpegcsharp\ -module dcmjpeg -namespace dcmjpeg dcmjpeg.i

... and it throws many errors that it is unable to find headers files (which are included inside these listed in the script). For example, header file "include/dcmtk/dcmjpeg/ddpiimpl.h" is including file "dcmtk/config/osconfig.h" which is in completely different location.

The problem is that the C++ headers files in DCMTK library's source code are scattered across multiple folders, and they "don't see each other". Is there a simple solution for that? Maybe to force SWIG to automatically and recursively search for headers files in some root directory of DCMTK source?

like image 801
Signum Avatar asked Mar 08 '26 11:03

Signum


1 Answers

Also, check out FO-DICOM (formerly mDCM), and the ClearCanvas API (built on mDCM). I've found them much easier to work with than DCMTk wrapped for C#.

like image 104
Will Bonde Avatar answered Mar 10 '26 00:03

Will Bonde