Thanks for your suggestion Stefan, it works well.

The product I work on has scripting in multiple languages built-in to the executable and we use SWIG to generate the application specific API for each language. For historical reasons the implementation of the API must reside in the main application executable and this is why I link the SWIG C++ output for each language into the application executable and each scripting language wrapper calls the functions exposed by the executable. Ideally I would have had a separate shared library for each supported language, but the way it is done works fine and does not require sweeping changes to our build system.



On 30 August 2011 01:14, Stefan Zager <> wrote:
On Fri, Aug 26, 2011 at 9:10 AM, Andrew Ward
<> wrote:
> Hello,
> Is there a way to change the "SwigDirector_" prefix on the SWIG generated
> C++ implementation of director classes to be language specific, but keep the
> wrapper class name the same over multiple languages.
> The reason I ask is that I link the SWIG C++ output for both C# and Python
> into the same module and I get a linker error because both SWIG generated
> C++ director classes have the same name.

You might be able to write some macros into a header file which you
#include from the SWIG generated wrappers:

in csharp_swig_macros.h:

#define SwigDirector_Foo CSharp_SwigDirector_Foo

in python_swig_macros.h:

#define SwigDirector_Foo Python_SwigDirector_Foo

in module.i:

%header {
# include "python_swig_macros.h"
# include "csharp_swig_macros.h"

Now, I have to ask: what is the nature of your project, that you would
want to link wrapper files into a single module?  I just can't imagine
why that would be useful.