Re: Embedding SWIG bindings for multiple languages in a single executable
Julien Marrec <[email protected]> Tue, 29 Jun 2021 09:44:37 +0200
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CAEqKKtxnD0dM8XATXqLKCQB8p_JMc5KjhW1cZZYyf5r-mGahdQ@mail.gmail.com> |
Thank you Alexey, I will look into your link. I cannot get rid of ruby unfortunately as our entire ecosystem relies on them (for eg: we actually support a Trimble sketchup plugin that makes use of these ruby bindings). What I'm really trying to do is to *add* *python* support. For the time being, I realized the problem was really for SwigDirector, so in python I do %rename on the few classes for which I enabled the director feature, which circumvents the issue (it's not great but it's a work around for now). The next big thing I found was to just avoid including stl.i (really just including std_vector.i which seems to be the guilty one), that's unfortunate but it avoids problems. My working MCVE of a static executable that embeds both python, ruby and the respective swig bindings is at https://github.com/jmarrec/Cpp_Swig_Ruby_Python_MCVE/tree/c+%2B-driver-try-ruby-static if anyone is curious (comments welcome too) Best, Julien -- Julien Marrec, EBCP, BPI MFBA Owner at EffiBEM <http://www.effibem.com> T: +33 6 95 14 42 13 LinkedIn (en <https://www.linkedin.com/in/julienmarrec>) *| *(fr <https://fr.linkedin.com/in/julienmarrec/fr>) : <http://www.linkedin.com/in/julienmarrec> Le mer. 23 juin 2021 à 13:44, Alexey Sokolov <[email protected]> a écrit : > 07.05.2021 16:01, Julien Marrec пишет: > > Hello, > > > > We have a C++ project, and are exporting ruby and python bindings. > > > > We wish to create a C++ CLI that embeds these bindings, so we can talk > > to both python and ruby from C++. The goal is that users could write > > small scripts in either ruby or python and they would be evaluated by > > the C++ driver. > > > > The problem we are facing is that SWIG exports the same names for both > > Ruby and Python, and when calling a *python* script at some point it > > ends up calling the method from the *ruby* library instead. > > The TYPES TABLES looks exactly the same on the ruby wrapper and the > > python wrapper. > > (I originally got another name clash with the `SwigDirector_T` but I'm > > using a `#ifdef SWIGPYTHON; %rename("Python%s") "";` directive for the > > time being) > > > > Is there a way to avoid this conflict? Perhaps adding a top-level > > namespace, or renaming the mangled types? > > I tried overriding the `%define mangle(Type)` macro, which worked for > > stl types but not for my types since it's actually not using it (seems > > like `typesys.c` harcodes it to `SWIGTYPE%s`). > > > > Has someone got an example of embedding SWIG bindings for two different > > languages in the same executable? I realize this may not be your usual > > use case scenario, but it's worth a shot :) > > ZNC embeds perl and python, so didn't have this specific issue. Those > names don't clash. > But the code is under modperl/ and modpython/ at > https://github.com/znc/znc/tree/master/modules > > Can I suggest replacing ruby bindings with perl? :) > > > > > Thank you, > > Julien > > > > > > PS: I asked a similar question in February > > (https://sourceforge.net/p/swig/mailman/swig-user/?viewmonth=202102 > > <https://sourceforge.net/p/swig/mailman/swig-user/?viewmonth=202102>), > > which was trying to use ruby to call python, but failing to do so I'm > > exploring a C++ driver now > > -- > > Julien Marrec, EBCP, BPI MFBA > > Owner at EffiBEM <http://www.effibem.com> > > T: +33 6 95 14 42 13 > > > > LinkedIn (en <https://www.linkedin.com/in/julienmarrec>)/| /(fr > > <https://fr.linkedin.com/in/julienmarrec/fr>) : > > <http://www.linkedin.com/in/julienmarrec> > > > > > > _______________________________________________ > > Swig-user mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/swig-user > > > > > -- > Best regards, > Alexey "DarthGandalf" Sokolov > > > _______________________________________________ > Swig-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/swig-user > _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user