Hi Russel, all: I believe what is missing is that the environment variable CHPL_LIBMODE needs to be set to 'shared' when compiling both the Chapel compiler and the code you wanted exported. I believe it will only work with certain settings (any use of third-party packages will lead to a headache that we haven't ironed out yet, so no qthreads or GMP, e.g.). Our Python interoperability makes use of this feature in order to work, and I believe is the place we most heavily exercise the feature.
Please let us know of any problems you encounter. As Brad said, it's not as widely used so there may be bugs we're not aware of. Thanks, Lydia Duncan On 09/10/2015 07:38 AM, Brad Chamberlain wrote: > Two additional notes: > > a) I'm noticing that --library is a "developer" flag which > is why it doesn't show up in --help or the man page, > and this probably suggests that it's not completely > ready for prime-time yet. > > b) It turns out that while I get a .a, when I try to link it > into a C program, I get similar ld errors as in the .so > case. > > So I'm hoping Lydia has some good hints for us. > > -Brad > > ________________________________________ > From: Brad Chamberlain [[email protected]] > Sent: Thursday, September 10, 2015 7:33 AM > To: Michael Ferguson; Russel Winder; Chapel_Users > Subject: RE: shared objects / dynamic link libraries > > Perhaps I shouldn't add to the uncertainty, but I wanted > to note that: > > 0) I don't think this feature has been used or exercised > much, so I always worry about how much weight it > can support at present. > > That said, my impression is that you should be able to: > > 1) declare some of your symbols as 'export' as Michael > suggests > > 2) compile with the --library flag to get a library rather > than an exeutable. > > The above seems to work for me and generate a .a > file. I then thought that: > > 3) using the --dynamic flag would generate a .so > library > > but instead I got ld errors. So, like Michael, I'm hoping > Lydia might have more information about how the Python > interoperability makes use of this (because I think it does). > > Best wishes, > -Brad > > ________________________________________ > From: Michael Ferguson [[email protected]] > Sent: Thursday, September 10, 2015 7:18 AM > To: Russel Winder; Chapel_Users > Subject: Re: shared objects / dynamic link libraries > > Hi - > > It's possible to mark function to be callable from C > using the 'export' keyword (similar in use to 'extern'). > You can use that to call back in to Chapel from C code. > > I'm less clear on whether or not you can actually create > > a shared library with the Chapel compiler. The Python integration > might have some capabilities along these lines, but I'm not so > familiar with it. Perhaps Lydia (cc'd) can fill us in on > that part? > > In any case, if all the Chapel code to be dynamically > linked together is compiled to a single shared object, > and then loaded from a C program (e.g.), there aren't > any significant technical barriers. I think it would > be mostly a matter of modifying the Makefiles that run > to generate the final binary and not including main(). > There are challenges though if you want to dynamically load > 2 different Chapel libraries and have them interoperate. > (I'm not saying such a thing could never work - just that > it will require some effort to achieve). > > Let me know if you'd like to try modifying the Makefiles > and I can offer some pointers. > > Best, > > -michael > > On 9/10/15, 6:26 AM, "Russel Winder" <[email protected]> wrote: > >> Maybe I should already know the answerĊ maybe this is a question I >> should have asked long agoĊ >> >> Is there a way of creating a shared object / dynamic link library with >> C linkage exports from Chapel code? >> >> Clearly Chapel can use C linkage libraries, but the reverse is much >> more interesting. >> >> -- >> Russel. >> ========================================================================== >> === >> Dr Russel Winder t: +44 20 7585 2200 voip: >> sip:[email protected] >> 41 Buckmaster Road m: +44 7770 465 077 xmpp: [email protected] >> London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder >> > > ------------------------------------------------------------------------------ > Monitor Your Dynamic Infrastructure at Any Scale With Datadog! > Get real-time metrics from all of your servers, apps and tools > in one place. > SourceForge users - Click here to start your Free Trial of Datadog now! > http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140 > _______________________________________________ > Chapel-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/chapel-users > > ------------------------------------------------------------------------------ > Monitor Your Dynamic Infrastructure at Any Scale With Datadog! > Get real-time metrics from all of your servers, apps and tools > in one place. > SourceForge users - Click here to start your Free Trial of Datadog now! > http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140 > _______________________________________________ > Chapel-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/chapel-users > > ------------------------------------------------------------------------------ > Monitor Your Dynamic Infrastructure at Any Scale With Datadog! > Get real-time metrics from all of your servers, apps and tools > in one place. > SourceForge users - Click here to start your Free Trial of Datadog now! > http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140 > _______________________________________________ > Chapel-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/chapel-users ------------------------------------------------------------------------------ Monitor Your Dynamic Infrastructure at Any Scale With Datadog! Get real-time metrics from all of your servers, apps and tools in one place. SourceForge users - Click here to start your Free Trial of Datadog now! http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140 _______________________________________________ Chapel-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/chapel-users
