digitalmars.D.learn - libphobos.so and loading libraries at runtime
- FreeSlave (28/28) Jan 05 2014 import core.runtime;
- Sean Kelly (3/32) Jan 07 2014 This seems like a weird change if intentional, since the function
- Dicebot (4/6) Jan 07 2014 It is. It works pretty good in practice but Martin wanted to
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__T11loadLibraryZ11loadL
braryFxAaZPv+0x4d):
undefined reference to `rt_loadLibrary'
main.o: In function
`_D4core7runtime7Runtime19__T13unloadLibraryZ13unloadLibraryFPvZb':
main.d:(.text._D4core7runtime7Runtime19__T13unloadLibraryZ13unlo
dLibraryFPvZb+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.
Jan 05 2014
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__T11loadLibraryZ11loadL
braryFxAaZPv+0x4d):
undefined reference to `rt_loadLibrary'
main.o: In function
`_D4core7runtime7Runtime19__T13unloadLibraryZ13unloadLibraryFPvZb':
main.d:(.text._D4core7runtime7Runtime19__T13unloadLibraryZ13unlo
dLibraryFPvZb+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.
Jan 07 2014
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.
Jan 07 2014









"Sean Kelly" <sean invisibleduck.org> 