Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Having trouble with SharedLib

Moderators: larsivi kris

Posted: 10/08/08 19:45:14

Hi all. I'm trying to familiarize myself with the sys.SharedLib? module. Using as a reference, I put together what should be a trivial case -- loading a single shared library. To my great frustration and dismay, I failed to even get this simplest case to work. DSSS spits back the following when I attempt to build:

dsss_objs/G/tango.sys.SharedLib?.o: In function `_D5tango3sys9SharedLib9SharedLib5load_MFE5tango3sys9SharedLib9SharedLib8LoadModeZv':
SharedLib?.d:(.text+0x5e4): undefined reference to `dlopen'
SharedLib?.d:(.text+0x60e): undefined reference to `dlerror'
dsss_objs/G/tango.sys.SharedLib?.o: In function `_D5tango3sys9SharedLib9SharedLib10getSymbol_MFPaZPv':
SharedLib?.d:(.text+0x6c1): undefined reference to `dlerror'
SharedLib?.d:(.text+0x6d9): undefined reference to `dlsym'
SharedLib?.d:(.text+0x6e1): undefined reference to `dlerror'
SharedLib?.d:(.text+0x7ce): undefined reference to `dlsym'
dsss_objs/G/tango.sys.SharedLib?.o: In function `_D5tango3sys9SharedLib9SharedLib7unload_MFZv':
SharedLib?.d:(.text+0x7f7): undefined reference to `dlclose'
SharedLib?.d:(.text+0x813): undefined reference to `dlerror'
collect2: ld returned 1 exit status

My best guess is that some library is I'm neglecting to link-in some library, but an attempt to dig up any useful information based on this hunch proved fruitless. If anyone on the other end of the tube can help me out here, I'd greatly appreciate it (and so will my current project). Thanks!

Author Message

Posted: 10/09/08 06:09:46

you need libdl. That is the linker option -ldl, or for DSSS -L-ldl

Posted: 10/10/08 15:44:04

Wewt! It's working now!

...Sorta. For whatever reason, I'm unable to use xxNoThrow() functions -- getSymbolNoThrow(), for instance. According to the compiler, the symbols doesn't exist. This seems bizarre since when I checked the source, they're declared right alongside the non-NoThrow?() functions. I can't make sense of it, but at least it's usable. If anyone has a reason why these wouldn't work, I'd love to hear it.

Posted: 10/10/08 22:52:41

The noThrow functions aren't present in 0.99.7, they were added later.