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:


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

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?

Create python wrapper Using SWIG for C++ classes

I have c++ object files For example : example1.o and example2.o Is it possible to create a python wrapper class using SWIG? If yes how can I create using SWIG

C++ to C Wrapper using SWIG (for FLTK)

I need to generate wrapper to FLTK C++ classes to use it in pure C. I know, that SWIG can do that, and I know how to generate wrapper for C#, Python etc. But I do not know how to wrap C++ to C using S

How do I propagate C++ exceptions to Python in a SWIG wrapper library?

I’m writing a SWIG wrapper around a custom C++ library which defines its own C++ exception types. The library’s exception types are richer and more specific than standard exceptions. (For example, one

SWIG-generated C++ wrapper causes many compilation errors

I’m trying to wrap one class in a large C++ codebase for python using SWIG, and am having some problems compiling the generated C++ wrapper. I created a basic interface file, PCSearchResult.i: %modul

specify wrapper method prefix for C# SWIG

When SWIG (using C#) wraps a method, say void foo(); it will generate a wrapper method with a CSharp_ prefix like this: SWIGEXPORT void SWIGSTDCALL CSharp_foo() { foo(); } Is it possible to specify/

Creating swig wrapper for C++ (pointers) to python

I a very new to swig and I am trying to create a swig wrapper in order to use a few C++ files in python. I have the following C++ class. The following is a snippet of the code that I am trying to conv

Compiling a SWIG Python wrapper for a static library?

This is a noob question. I’m trying to learn how to use SWIG to make a python interface for a C++ library. The library is a proprietary 3rd party library; it comes to me in the form of a header file (

Is it possible to add code to an existing method when using Swig to build a C# wrapper for C++ code?

When using Swig to wrap C++ code, it is possible to add methods to the native C++ type using %extend. It is possible to add methods to the C# wrapper class using %typemap(cscode). Where a method alre

Why wrap a C++ library via a C interface using SWIG?

SWIG novice exploring the feasibility of wrapping a large C++ library primarily for Python access. Speaking with the developers working on the C++ one has proposed writing a C interop layer that is th

Using SWIG with pointer to function in C struct

I’m trying to write a SWIG wrapper for a C library that uses pointers to functions in its structs. I can’t figure out how to handle structs that contain function pointers. A simplified example follows


I know you asked specifically about DCMTK, so there could be very good reasons for that choice, however this info may be useful for you or others:

The other major Dicom tookit (GDCM) already has a C# wrapper, created using SWIG. GDCM is a mature Dicom library used in large products for Dicom IO, e.g. ITK..

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#.