www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Dub shared library issue

reply "Mineko" <uminekorox gmail.com> writes:
So, I can get a shared library compiled normally (Assuming it's 
already compiled first with -shared -fPIC etc) with: dmd 
-of'Breaker Engine.so' 'Breaker Engine.o' -shared 
-defaultlib=libphobos2.so -L-rpath=$PWD

However, for some reason dub is having issues whenever I try to 
compile it as a shared library with dynamicLibrary.

Any suggestions? I'd like to get this fixed because otherwise 
there's gonna be portability problems..
Jan 03 2014
parent reply "Mathias LANG" <pro.mathias.lang gmail.com> writes:
On Friday, 3 January 2014 at 15:01:16 UTC, Mineko wrote:
 So, I can get a shared library compiled normally (Assuming it's 
 already compiled first with -shared -fPIC etc) with: dmd 
 -of'Breaker Engine.so' 'Breaker Engine.o' -shared 
 -defaultlib=libphobos2.so -L-rpath=$PWD

 However, for some reason dub is having issues whenever I try to 
 compile it as a shared library with dynamicLibrary.

 Any suggestions? I'd like to get this fixed because otherwise 
 there's gonna be portability problems..
Could you provide some error message / output, and your package.json ?
Jan 03 2014
parent reply "Mineko" <uminekorox gmail.com> writes:
On Friday, 3 January 2014 at 15:03:27 UTC, Mathias LANG wrote:
 On Friday, 3 January 2014 at 15:01:16 UTC, Mineko wrote:
 So, I can get a shared library compiled normally (Assuming 
 it's already compiled first with -shared -fPIC etc) with: dmd 
 -of'Breaker Engine.so' 'Breaker Engine.o' -shared 
 -defaultlib=libphobos2.so -L-rpath=$PWD

 However, for some reason dub is having issues whenever I try 
 to compile it as a shared library with dynamicLibrary.

 Any suggestions? I'd like to get this fixed because otherwise 
 there's gonna be portability problems..
Could you provide some error message / output, and your package.json ?
Sure, I thought I was missing some info.. Linking... dmd -of.dub/build/library-debug-x86_64-dmd-DA39A3EE5E6B4B0D3255BFEF95601890AF 80709/libbreaker.so .dub/build/library-debug-x86_64-dmd-DA39A3EE5E6B4B0D3255BFEF956018 0AFD80709/breaker.o -L-ldl -shared -g /usr/bin/ld: /usr/lib/libphobos2.a(object__a_58c.o): relocation R_X86_64_32 against `_D10TypeInfo_m6__initZ' can not be used when making a shared object; recompile with -fPIC /usr/lib/libphobos2.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status { "name": "breaker-engine", "description": "A multi-dimensional engine with a stupid amount of modularity", "homepage": "https://github.com/ICGCC/Breaker-Engine", "license": "Zlib", "author": "Jakob Austin Wimberly (Mineko)", "targetName": "breaker", "targetPath": "lib", "targetType": "dynamicLibrary", "dependencies": { "gl3n": "~master", "derelict-gl3": "~master", "derelict-glfw3": "~master", "derelict-fi": "~master" } }
Jan 03 2014
parent reply "Mathias LANG" <pro.mathias.lang gmail.com> writes:
On Friday, 3 January 2014 at 15:10:54 UTC, Mineko wrote:
 On Friday, 3 January 2014 at 15:03:27 UTC, Mathias LANG wrote:
 On Friday, 3 January 2014 at 15:01:16 UTC, Mineko wrote:
 So, I can get a shared library compiled normally (Assuming 
 it's already compiled first with -shared -fPIC etc) with: dmd 
 -of'Breaker Engine.so' 'Breaker Engine.o' -shared 
 -defaultlib=libphobos2.so -L-rpath=$PWD

 However, for some reason dub is having issues whenever I try 
 to compile it as a shared library with dynamicLibrary.

 Any suggestions? I'd like to get this fixed because otherwise 
 there's gonna be portability problems..
Could you provide some error message / output, and your package.json ?
Sure, I thought I was missing some info.. Linking... dmd -of.dub/build/library-debug-x86_64-dmd-DA39A3EE5E6B4B0D3255BFEF95601890AF 80709/libbreaker.so .dub/build/library-debug-x86_64-dmd-DA39A3EE5E6B4B0D3255BFEF956018 0AFD80709/breaker.o -L-ldl -shared -g /usr/bin/ld: /usr/lib/libphobos2.a(object__a_58c.o): relocation R_X86_64_32 against `_D10TypeInfo_m6__initZ' can not be used when making a shared object; recompile with -fPIC /usr/lib/libphobos2.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status { "name": "breaker-engine", "description": "A multi-dimensional engine with a stupid amount of modularity", "homepage": "https://github.com/ICGCC/Breaker-Engine", "license": "Zlib", "author": "Jakob Austin Wimberly (Mineko)", "targetName": "breaker", "targetPath": "lib", "targetType": "dynamicLibrary", "dependencies": { "gl3n": "~master", "derelict-gl3": "~master", "derelict-glfw3": "~master", "derelict-fi": "~master" } }
Add this to your package.json: "libs": [ "phobos2" ] I also added: "lflags": [ "-rpath=/home/xxxx/bin/dmd-2.064.2/linux/lib64/" ], for myself, as my dmd is in ~/bin/, but you shouldn't need it if you installed the package.
Jan 03 2014
parent "Mineko" <uminekorox gmail.com> writes:
""libs": [ "phobos2" ]" worked perfectly, thank you so much. :)
Jan 03 2014