Thread overview
Issues creating a dynamic libary with dub
Mar 25, 2020
mitchell
Mar 25, 2020
rikki cattermole
Mar 25, 2020
mitchell
March 25, 2020
Hello,

I'm having issues creating a dynamic library with dub.
The dub config file contains (with the exception of the names and such) only

    targetType "dynamicLibrary"

When I attempt to buld the library, I get:

    common ~master: building configuration "library"...
    /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/5/libgphobos2.a(ascii.o): relocation R_X86_64_32S against `.data' can not be used when making a shared object; recompile with -fPIC
    /usr/lib/gcc/x86_64-linux-gnu/5/libgphobos2.a: error adding symbols: Bad value
    collect2: error: ld returned 1 exit status
    gdc failed with exit code 1.

I've been working with D for quite a while, but I've never really used dub. It looks like dub is attempting to attach phobos to the dynamic link library I'm trying to create. Is there something simple which I'm missing entirely?

I would have asked on the dub forums, but they seem to be down right now.
March 25, 2020
When I see -fPIC I think something is wrong with your compiler+runtime setup.

Use -v to see the commands dub is using. This should not be dub related.
March 25, 2020
On Wednesday, 25 March 2020 at 04:04:09 UTC, rikki cattermole wrote:
> When I see -fPIC I think something is wrong with your compiler+runtime setup.
>
> Use -v to see the commands dub is using. This should not be dub related.

It seems you're correct. I looked through some of the older projects I've made on this machine (ones where I used make instead of dub), I found that whenever I made a shared library, I always had to revert to using gcc, rather than gdc. I will need to examine my setup.

Thank you for the rapid response!