如何创建一个同时适用于多种语言的包装器

How to create a wrapper that would work for multiple languages at the same time?

本文关键字:适用于 语言 包装 一个 何创建 创建      更新时间:2023-10-16

我有一个简单的C API(N简单函数)。我想同时将它封装到C#、Java和Python中。如何调用SWIG同时为多种语言创建包装器?

像这样的

swig.exe-c++-csharp-java-namespace Bla-outdir./-o/BlaAPIWrapper.cxx BlaAPI.i

导致swig应用程序崩溃

Assertion failed: !this_, file Modules/lang.cxx, line 332
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

适用于每种语言。

只需用不同的参数多次调用它,一次用于Java,一次为C#等。

您可能需要一些shell脚本来实现自动化,但一旦创建了生成包装器的脚本,就只需调用该脚本。

如果swig不允许同时使用多种语言,或者该功能存在但被窃听(或者它存在但未记录,并且由于缺少重要信息而无法使用),这可能是最简单的解决方案。