digitalmars.D - Creating a .so shared object on linux.
- Daan Oosterveld (14/14) Mar 16 2005 Hi,
- John Reimer (7/31) Mar 16 2005 It's still /not/ possible to make a shared library on Linux. It's
- Anders Runesson (6/13) Mar 16 2005 GDC can indeed create shared objects, though I haven't tried actually
- John Reimer (6/24) Mar 16 2005 Yes... I should have clarified: they can be /created/ successfully with
- Daan Oosterveld (9/40) Mar 17 2005 Passing -fpic did give me a shared object with dmd as the compiler and
Hi, How do you create a .so shared object library on linux with DMD? I really like shared object libraries and saving memory space ;) I use the dmd compiler to link the .so with this command: dmd -L-shared -of/home/daan/purplecat/lib/default/libmysolibrary.so <object files here> I also tried to use gcc for linkage but both give me this error: /usr/bin/ld: /home/daan/purplecat/lib/default/libmysolibrary.so: undefined versioned symbol name _d_throw 4 /usr/bin/ld: failed to set dynamic section sizes: Bad value All other symbols get resolved except this one :( I am using 0.118, the program does compile when I use static linking. Or is it impossible to create an .so library? (which would be silly) Daan
Mar 16 2005
Daan Oosterveld wrote:Hi, How do you create a .so shared object library on linux with DMD? I really like shared object libraries and saving memory space ;) I use the dmd compiler to link the .so with this command: dmd -L-shared -of/home/daan/purplecat/lib/default/libmysolibrary.so <object files here> I also tried to use gcc for linkage but both give me this error: /usr/bin/ld: /home/daan/purplecat/lib/default/libmysolibrary.so: undefined versioned symbol name _d_throw 4 /usr/bin/ld: failed to set dynamic section sizes: Bad value All other symbols get resolved except this one :( I am using 0.118, the program does compile when I use static linking. Or is it impossible to create an .so library? (which would be silly) DaanIt's still /not/ possible to make a shared library on Linux. It's definitely been high on the Linux users wish list, though, for dmd. I'm not sure if gdc has succeeded yet either. But, if it did work, I think you have to provide -pic (along with -shared) to activate position independent code for the shared library. -JJR
Mar 16 2005
John Reimer wrote: > It's still /not/ possible to make a shared library on Linux. It'sdefinitely been high on the Linux users wish list, though, for dmd. I'm not sure if gdc has succeeded yet either. But, if it did work, I think you have to provide -pic (along with -shared) to activate position independent code for the shared library. -JJRGDC can indeed create shared objects, though I haven't tried actually using one of the generated objects so I'm not sure if it *really* works. Just pass -fPIC -shared when linking with gdc and you're set. /Anders Runesson
Mar 16 2005
Anders Runesson wrote:John Reimer wrote: > It's still /not/ possible to make a shared library on Linux. It'sYes... I should have clarified: they can be /created/ successfully with dmd on linux too. But they don't work when you try to link to them. gdc might have the same problem. -JJR PS thanks for the -fPIC correction. :-)definitely been high on the Linux users wish list, though, for dmd. I'm not sure if gdc has succeeded yet either. But, if it did work, I think you have to provide -pic (along with -shared) to activate position independent code for the shared library. -JJRGDC can indeed create shared objects, though I haven't tried actually using one of the generated objects so I'm not sure if it *really* works. Just pass -fPIC -shared when linking with gdc and you're set. /Anders Runesson
Mar 16 2005
John Reimer schreef:Anders Runesson wrote:Passing -fpic did give me a shared object with dmd as the compiler and gcc for linking. But when linking the .so to an executable it gave the same _d_throw 4 unresolved symbol. _d_throw? ... exception handling? I am going to try gdc. If that won't work I'll have to stick to static linking for a while ... ar ar ar ;) tnx for the info ..DaanJohn Reimer wrote: > It's still /not/ possible to make a shared library on Linux. It'sYes... I should have clarified: they can be /created/ successfully with dmd on linux too. But they don't work when you try to link to them. gdc might have the same problem. -JJR PS thanks for the -fPIC correction. :-)definitely been high on the Linux users wish list, though, for dmd. I'm not sure if gdc has succeeded yet either. But, if it did work, I think you have to provide -pic (along with -shared) to activate position independent code for the shared library. -JJRGDC can indeed create shared objects, though I haven't tried actually using one of the generated objects so I'm not sure if it *really* works. Just pass -fPIC -shared when linking with gdc and you're set. /Anders Runesson
Mar 17 2005