www.digitalmars.com         C & C++   DMDScript  

D - Shared libs on Linux

reply Stephan Wienczny <wienczny web.de> writes:
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
Apr 16 2004
parent reply David Friedman <d3rdclsmail earthlink.net> writes:
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
Apr 16 2004
next sibling parent reply Stephan Wienczny <wienczny web.de> writes:
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
Apr 16 2004
next sibling parent Lars Ivar Igesund <larsivar igesund.net> writes:
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
Apr 17 2004
prev sibling parent David Friedman <d3rdclsmail earthlink.net> writes:
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



LIBTOOL=`which glibtool || which libtool`










$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




$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
Apr 17 2004
prev sibling parent reply Mike Hearn <mike navi.cx> writes:
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
Apr 17 2004
parent serge <serge lxnt.info> writes:
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.
Apr 17 2004