Thread overview | |||||
---|---|---|---|---|---|
|
January 05, 2014 libphobos.so and loading libraries at runtime | ||||
---|---|---|---|---|
| ||||
import core.runtime; int main() { Runtime.loadLibrary("does not care"); Runtime.unloadLibrary(null); return 0; } When I try to compile this code with 'dmd main.d', I get errors main.o: In function `_D4core7runtime7Runtime17__T11loadLibraryZ11loadLibraryFxAaZPv': main.d:(.text._D4core7runtime7Runtime17__T11loadLibraryZ11loadLibraryFxAaZPv+0x4d): undefined reference to `rt_loadLibrary' main.o: In function `_D4core7runtime7Runtime19__T13unloadLibraryZ13unloadLibraryFPvZb': main.d:(.text._D4core7runtime7Runtime19__T13unloadLibraryZ13unloadLibraryFPvZb+0x8): undefined reference to `rt_unloadLibrary' But it's built without errors when I separate compile and link parts: dmd -c main.d gcc main.o -lphobos2 -o main I checked libraries with nm utility and actually found no such symbols in static version of libphobos. But shared one has these symbols. Well, I'm aware of that runtime loading requires shared version of phobos2 to avoid duplicating of D runtime. But why does dmd use static linking by default? Is shared version of phobos still experimental? Anyway we need some remarks in documentation about the lack of these functions in static version of phobos. |
January 07, 2014 Re: libphobos.so and loading libraries at runtime | ||||
---|---|---|---|---|
| ||||
Posted in reply to FreeSlave | On Sunday, 5 January 2014 at 20:47:44 UTC, FreeSlave wrote:
> import core.runtime;
>
> int main()
> {
> Runtime.loadLibrary("does not care");
> Runtime.unloadLibrary(null);
> return 0;
> }
>
> When I try to compile this code with 'dmd main.d', I get errors
>
> main.o: In function `_D4core7runtime7Runtime17__T11loadLibraryZ11loadLibraryFxAaZPv':
> main.d:(.text._D4core7runtime7Runtime17__T11loadLibraryZ11loadLibraryFxAaZPv+0x4d): undefined reference to `rt_loadLibrary'
> main.o: In function `_D4core7runtime7Runtime19__T13unloadLibraryZ13unloadLibraryFPvZb':
> main.d:(.text._D4core7runtime7Runtime19__T13unloadLibraryZ13unloadLibraryFPvZb+0x8): undefined reference to `rt_unloadLibrary'
>
> But it's built without errors when I separate compile and link parts:
> dmd -c main.d
> gcc main.o -lphobos2 -o main
>
> I checked libraries with nm utility and actually found no such symbols in static version of libphobos. But shared one has these symbols.
>
> Well, I'm aware of that runtime loading requires shared version of phobos2 to avoid duplicating of D runtime. But why does dmd use static linking by default? Is shared version of phobos still experimental? Anyway we need some remarks in documentation about the lack of these functions in static version of phobos.
This seems like a weird change if intentional, since the function is publicly declared. I'd file a bug report.
|
January 07, 2014 Re: libphobos.so and loading libraries at runtime | ||||
---|---|---|---|---|
| ||||
Posted in reply to FreeSlave | On Sunday, 5 January 2014 at 20:47:44 UTC, FreeSlave wrote:
> But why does dmd use static linking by default? Is shared version of phobos still experimental?
It is. It works pretty good in practice but Martin wanted to improve provided utilities for library/symbol loading before announcing it as released AFAIR.
|
Copyright © 1999-2021 by the D Language Foundation