Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
April 16, 2004 Shared libs on Linux | ||||
---|---|---|---|---|
| ||||
Hallo, is it possible to create shared libs? The dmd docs say its not yet possible. Can it be done using the gcc frontend? Stephan |
April 16, 2004 Re: Shared libs on Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephan Wienczny | The gcc front end can produce shared libraries, but there may some issues with Phobos itself not (yet) being shared library. The only thing I know will not work is static constructors and destructors in dynamically loaded modules.
David
Stephan Wienczny wrote:
> Hallo,
>
> is it possible to create shared libs?
> The dmd docs say its not yet possible. Can it be done using the gcc frontend?
>
> Stephan
|
April 16, 2004 Re: Shared libs on Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Friedman | David Friedman wrote:
> The gcc front end can produce shared libraries, but there may some issues with Phobos itself not (yet) being shared library. The only thing I know will not work is static constructors and destructors in dynamically loaded modules.
>
> David
>
> Stephan Wienczny wrote:
>
>> Hallo,
>>
>> is it possible to create shared libs?
>> The dmd docs say its not yet possible. Can it be done using the gcc frontend?
>>
>> Stephan
>
>
I tryed using aap to create a d lib. The the docs it says it is not possible...
Is it possible to create a lib using the GDC project?
Stephan
|
April 17, 2004 Re: Shared libs on Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephan Wienczny | Stephan Wienczny wrote: > David Friedman wrote: > >> The gcc front end can produce shared libraries, but there may some issues with Phobos itself not (yet) being shared library. The only thing I know will not work is static constructors and destructors in dynamically loaded modules. >> >> David >> >> Stephan Wienczny wrote: >> >>> Hallo, >>> >>> is it possible to create shared libs? >>> The dmd docs say its not yet possible. Can it be done using the gcc frontend? >>> >>> Stephan >> >> >> > I tryed using aap to create a d lib. The the docs it says it is not possible... The A-A-P docs are slightly inaccurate, because support for GDC isn't added. DMD isn't able to create shared libs on Linux. A-A-P should be able to create static libs on Linux using DMD, but I have personally never tested it. It might fail miserably. > Is it possible to create a lib using the GDC project? Support for GDC will be added to A-A-P, but I don't really have the equipment to test it properly myself at the moment. Whether GDC as a standalone program is able to do what you want, I can't say. Lars Ivar Igesund |
April 17, 2004 Re: Shared libs on Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Friedman | On Fri, 16 Apr 2004 19:02:56 -0400, David Friedman wrote:
> The gcc front end can produce shared libraries, but there may some issues with Phobos itself not (yet) being shared library. The only thing I know will not work is static constructors and destructors in dynamically loaded modules.
I should note that unless the output of gdc has a stable ABI (unlikely given that D itself isn't stable yet), shared libraries are mostly useless as nobody other than yourself can reliably link to them.
You might be tempted to split a single project into shared libraries - resist! There are no real performance gains to be had from this approach and in fact, there will probably be severe performance penalties. Combining everything into one large static binary is probably the best way for now.
We need a stable D (and ABI) to really kick off with good language bindings and 3rd party D libs, so I'd really like to know how soon this might occur.
thanks -mike
|
April 17, 2004 Re: Shared libs on Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Hearn | In article <pan.2004.04.17.11.05.11.747580@navi.cx>, Mike Hearn says... >On Fri, 16 Apr 2004 19:02:56 -0400, David Friedman wrote: >> The gcc front end can produce shared libraries, but there may some issues with Phobos itself not (yet) being shared library. The only thing I know will not work is static constructors and destructors in dynamically loaded modules. > >I should note that unless the output of gdc has a stable ABI (unlikely given that D itself isn't stable yet), shared libraries are mostly useless as nobody other than yourself can reliably link to them. > >You might be tempted to split a single project into shared libraries - resist! There are no real performance gains to be had from this approach and in fact, there will probably be severe performance penalties. Combining everything into one large static binary is probably the best way for now. > >We need a stable D (and ABI) to really kick off with good language bindings and 3rd party D libs, so I'd really like to know how soon this might occur. But what about using shared library written in D language from existing C++ project? If I understand it right, D is ABI is compatible with C. I would like to try porting some of my code to D, but converting entire project is too time consuming and error prone. Converting it one module at a time probably is safer. Anyway, I'm not so interested in shared libraries right now, but I would like to be able to link D and C code together in one project (most of the code written in C/C++ and a few D modules). I still did not make any experiments, maybe it is already possible, but absence of shared libraries support seems a bad sign to me. |
April 17, 2004 Re: Shared libs on Linux | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephan Wienczny | Here's a little formula for building a shared library using libtool and gdc. If you don't like libtool's '.lo','.la' stuff, you can still use it to figure out what magic commands are needed to build shared libraries for your OS.
David
#!/bin/sh
# libtool is 'glibtool' on MacOS X
LIBTOOL=`which glibtool || which libtool`
# Prevent linking against (the currently static) libphobos.
# This is probably the right thing to do for now. I ended up
# not needing it because libtool used 'gcc' instead of 'gdc'.
# NOSTDLIB=-nostdlib
# Build the shared library.
# Note: The argument to -rpath is where you will install the library.
# I am using '.libs' here to keep it simple.
# Note: The --tag argument is only needed for recent libtools (?)
$LIBTOOL --tag=CC --mode=compile gdc -c -o shllib.lo shllib.d
$LIBTOOL --tag=CC --mode=link gdc $NOSTDLIB -o libshllib.la \
shllib.lo -rpath `pwd`/.libs
# Link against the library. You may need to export
# LD_LIBRARY_PATH=`pwd`/.libs depending on your OS to get
# the program to run.
$LIBTOOL --tag=CC --mode=link gdc -o shlusr shlusr.d libshllib.la
Stephan Wienczny wrote:
> David Friedman wrote:
>
>> The gcc front end can produce shared libraries, but there may some issues with Phobos itself not (yet) being shared library. The only thing I know will not work is static constructors and destructors in dynamically loaded modules.
>>
>> David
>>
>> Stephan Wienczny wrote:
>>
>>> Hallo,
>>>
>>> is it possible to create shared libs?
>>> The dmd docs say its not yet possible. Can it be done using the gcc frontend?
>>>
>>> Stephan
>>
>>
>>
> I tryed using aap to create a d lib. The the docs it says it is not possible...
> Is it possible to create a lib using the GDC project?
>
> Stephan
|
Copyright © 1999-2021 by the D Language Foundation