Community

If i want to put dwt into a dynamic lib, then i have those components
- D runtime (tango)
- dwt (either dwt-win or dwt-linux, depends on tango)
- dwt-addons (optionally, dependending on dwt-win/dwt-linux and tango)
- application code, depending on all above.
What i want to do is, to put all dwt and dwt-addons stuff into two libs.
I hope to get shorter build times and smaller executables.
Is that possible on win/linux?
What are the problems?
As far as I remember, Walter said at the conference that DMD /does/
generate pic (position independent code) and it /should/ work. If there
are problems, he would need examples and/or bug reports. Are there
problems? Are there reports?

Frank Benoit wrote:
> If i want to put dwt into a dynamic lib, then i have those components
>
> - D runtime (tango)
> - dwt (either dwt-win or dwt-linux, depends on tango)
> - dwt-addons (optionally, dependending on dwt-win/dwt-linux and tango)
> - application code, depending on all above.
>
> What i want to do is, to put all dwt and dwt-addons stuff into two libs.
>
> I hope to get shorter build times and smaller executables.
>
> Is that possible on win/linux?
> What are the problems?
>
> As far as I remember, Walter said at the conference that DMD /does/
> generate pic (position independent code) and it /should/ work. If there
> are problems, he would need examples and/or bug reports. Are there
> problems? Are there reports?
>
First of all, with Windows, you can already create DLLs and use them
now. It also has nothing whatsoever to do with PIC. There is an example
on doing Windows DLLs in the samples directory.
Shared libraries under Linux are completely different. The compiler does
generate PIC code, so the compiler work is done, but nobody has sat down
and figured out the details of making Phobos work as a shared library.

Walter Bright a écrit :
> Shared libraries under Linux are completely different. The compiler does
> generate PIC code, so the compiler work is done, but nobody has sat down
> and figured out the details of making Phobos work as a shared library.
Frank Benoit does not need to compile Phobos as a shared library to do
what he wants to do. So the answer is yes, it's possible.

Frank Benoit a écrit :
> If i want to put dwt into a dynamic lib, then i have those components
>
> - D runtime (tango)
> - dwt (either dwt-win or dwt-linux, depends on tango)
> - dwt-addons (optionally, dependending on dwt-win/dwt-linux and tango)
> - application code, depending on all above.
>
> What i want to do is, to put all dwt and dwt-addons stuff into two libs.
>
> I hope to get shorter build times and smaller executables.
>
> Is that possible on win/linux?
> What are the problems?
On Windows, I don't know. On Linux, I have already compiled a D shared
library with no problems whatsoever. I'm using GDC, but if DMD supports
PIC you should be just fine.
Just remember not to include Phobos/Tango when creating your shared
library (it won't work, because Phobos/Tango is not compiled PIC). With
GDC you can avoid linking to Phobos/Tango using the -nophoboslib switch.
I don't know for DMD. Of course, you still have to link to Phobos/Tango
when building the actual application.
However, when maintaining shared libraries, automatic function inlining
might cause problems. See the "library standardization" thread for details.

e-t172 schrieb:
> On Windows, I don't know. On Linux, I have already compiled a D shared
> library with no problems whatsoever. I'm using GDC, but if DMD supports
> PIC you should be just fine.
>
> Just remember not to include Phobos/Tango when creating your shared
> library (it won't work, because Phobos/Tango is not compiled PIC). With
> GDC you can avoid linking to Phobos/Tango using the -nophoboslib switch.
> I don't know for DMD. Of course, you still have to link to Phobos/Tango
> when building the actual application.
>
> However, when maintaining shared libraries, automatic function inlining
> might cause problems. See the "library standardization" thread for details.
Did you use the example code from the digitalmars windows example?
Can you post a minimized linux example?
Can "new MyClass" be called?
Have you tried with exceptions crossing the lib boundary? (bug #1693)
Not linking tango you mean just the tango-base-dmd.a, like supplying an
empty dummy.a ?

I would like to collect as much information as possible.
Windows:
Looking at the DLL example, it looks like DLLs are fully supported.
- Has someone used this successfully?
- Bug #1693 (DLLs and exceptions) seems to be a show stopper for the dwt
into a DLL project?
- Why isn't it possible to call "new MyClass" instead of "getMyClass"?
D runtime:
- What are the problems, doing it into a dyn. lib?

Frank Benoit wrote:
> I would like to collect as much information as possible.
>
> Windows:
> Looking at the DLL example, it looks like DLLs are fully supported.
> - Has someone used this successfully?
> - Bug #1693 (DLLs and exceptions) seems to be a show stopper for the dwt
> into a DLL project?
I don't know. Haven't investigated it.
> - Why isn't it possible to call "new MyClass" instead of "getMyClass"?
??
>
> D runtime:
> - What are the problems, doing it into a dyn. lib?
>
I don't know. It hasn't been investigated.

Frank Benoit a écrit :
> Did you use the example code from the digitalmars windows example?
No. I don't develop on Windows.
> Can you post a minimized linux example?
I don't see the point. As far as I know, any D code can be made into a
shared library. Just compile it with PIC and create the library.
> Can "new MyClass" be called?
Yes, why not?
> Have you tried with exceptions crossing the lib boundary? (bug #1693)
IIRC, yes. And it works.
> Not linking tango you mean just the tango-base-dmd.a, like supplying an
> empty dummy.a ?
I don't use DMD, so I can't tell for sure. I don't see any reason why
this wouldn't work, though.