最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Build several SWIG interface files under same module - Stack Overflow

programmeradmin0浏览0评论

I have several c++ files & classes under different namespaces that are compiled to the same dll and I want to create corresponding C# API via SWIG interfaces.FileCPP1:

namespace First
{
    class MyClass1 {
    public:
        MyClass1() = default;
        void HelloWorld(const std::string& msg) { cout << "Hello World!" << msg << endl;}
    };
}

FileCPP2:

namespace Second {
    class MyClass2 {
    public:
      MyClass2() = default;
      void HelloWorldAgain(const std::string& msg) { cout << "Hello World again!" << msg << endl;}
     };
}

I tried to do: MyClass1.i file:

%include "std_string.i"
%typemap(csclassmodifiers) First::MyClass1
namespace First {
    class MyClass1 {
      MyClass1();
      void HelloWorld(const std::string& msg);
    };
}

build line: swig.exe -c++ -csharp -DSWIG2_CSHARP -outdir CSFolder -namespace First -module Base

MyClass2.i file:

%include "std_string.i"
%typemap(csclassmodifiers) Second::MyClass2
namespace Second{
    class MyClass2 {
      MyClass2();
      void HelloWorldAgain(const std::string& msg);
    };
}

build line: swig.exe -c++ -csharp -DSWIG2_CSHARP -outdir CSFolder -namespace Second -module Base

Base.i file:

%module Base

%include "MyClass1.i"
%include "MyClass2.i"

build line:

swig.exe -c++ -csharp -DSWIG2_CSHARP -outdir CSFolder

I expect to get in BasePINVOKE.cs file that contains invoke methods from both MyCalss1 and MyClass2, but after build I get randomly only one of those classes invoke methods. All other files are generated as expected. The same happens when I replace "include" with "import". Some ideas what I do wrong?

Try to create SWIG interface of several ".i" that are belong to same dll and different namespace in each file.

发布评论

评论列表(0)

  1. 暂无评论