[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Using multiple modules with Swig -> Lua
- From: "Robert Osfield" <robert.osfield@...>
- Date: Fri, 12 May 2006 15:23:10 +0100
Hi,
I'm currently using Swig to wrap a C++ classes that come from several
different libraries, each of which has its own namespace. I'd
like to map the module name to namespace library name. Does Swig
-> Lua support this?
I have been successful is getting a single Swig .i file, which includes
all the classes together under a single module name, to build, link and
work at runtime - but all the different classes are under the same
module name. I have tried the following approach to split the
respectively classes into appropriate modules:
1) Creating a single Swig .i with multiple %module names in it, with
the appropriate declaration before each so it looks something like:
%module lib1
%{
#include <lib1/class1>
%}
namespace lib1
{
class Class1
{...
};
};
%module lib2
%{
#include <lib2/class2>
%}
namespace lib2
{
class Class2
{...
};
};
While swig ran without reported errors on the .i file, the compiled and linked ok, but everything was
built as module lib1.
So my next attempt was:
2. Created two separate .i files, one for module lib1, and one
for module lib2, swig ran cleanly on both, and the compilation of the
resulting c++ files was successful, but at link stage I got a
multiple definition of `SWIG_init_user'
By hacking the swig autogenerated c++ files to have separate versions of SWIG_init_user I got
things to compile and link. However, manually editing files isn't viable, especially considering
the early stage I'm at, requiring regular rebuilds using swig when I alter the source .i files.
I'd appreciate suggestions/wisdom of how to tackle multiple modules, or whether I should just stick with a single model.
Thanks in advance,
Robert.