lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello Robert,

I am the maintainer of the Lua part of SWIG. I will try to help you on this one.

Each SWIG .i file is for one library, and each one needs one %module.
The code will not allow more than one module in a single file.

As you figured out, you can have many .i files, one per module. Each one has its own namespace (so to speak).

For you to get the compiler error, I reckon you must be static linking. If you use dynamic linking (ie each to a DLL/SO) it doesn't happen.
The reason for this is that there are a few bits of common code found in each of the SWIG wrapper files. And they seem to be conflicting with each other.

A quick fix, would be something like either a global search-replace for each file.
Or if you add the following into the your .i file
%module lib1
%{
#define SWIG_init_user SWIG_init_user_lib1
%}

%module lib2
%{
#define SWIG_init_user SWIG_init_user_lib2
%}

This would remove the conflict by renaming the conflicting function. (You would have to have a different unique name for each module, its ugly, but at least it means you don't need to edit the generated file).

Let me go back an look at the code and I will give you some more advice later.

Regards,
Mark Gossage

PS. For swig related questions, you can also post to the SWIG mailing list