digitalmars.D - Shared object with Sqlite?
- Benjiro (14/30) Dec 12 2016 A silly question that has me pounding my head for a while. I am
- Mike Parker (6/21) Dec 12 2016 Right, because there's no linking taking place when you compile
- Benjiro (6/11) Dec 12 2016 From my understanding, because the libdll has a shared tag, the
- Mike Parker (4/8) Dec 12 2016 If you can't get DMD to pass the proper linker flags, you should
- Benjiro (4/13) Dec 14 2016 Thanks. Simply ended up linking to the shared library. Not what i
A silly question that has me pounding my head for a while. I am trying to compile a shared object WITH sqlite3 included into the shared object.dmd -c dll.d -fPIC -L-ldl -L/usr/lib/x86_64-linux-gnu/libsqlite3.a dmd -oflibdll.so dll.o -shared -defaultlib=libphobos2.so -L-rpath=/root/dlangProjectsNo ability to access the C object. It does not even seem to be included based upon the file size. This works ( using the already existing shared sqlite3 object ) but i am just linking the sqlite3 to the shared object.dmd -c dll.d -fPIC dmd -oflibdll.so dll.o -shared -defaultlib=libphobos2.so -L-rpath=/root/dlangProjects -L/usr/lib/x86_64-linux-gnu/libsqlite3.soAnd for fun... this one just errors out big time ;)dmd -c dll.d -fPIC dmd -oflibdll.so dll.o -shared -defaultlib=libphobos2.so -L-ldl -L/usr/lib/x86_64-linux-gnu/libsqlite3.a /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libsqlite3.a(sqlite3.o): relocation R_X86_64_PC32 against symbol `sqlite3_strnicmp' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit statusThe goal is to have the sqlite3 embedded into the shared object so i can have my own orm in D build into the dll.d ( for easy distribution ). And then my main programs can dynamically load this shared object. Complicated. I am probably mixing things up but its a bit of experimentation. ;)
Dec 12 2016
On Monday, 12 December 2016 at 13:12:35 UTC, Benjiro wrote:A silly question that has me pounding my head for a while. I am trying to compile a shared object WITH sqlite3 included into the shared object.Right, because there's no linking taking place when you compile dll.d. The -c option means compile only. The link step happens in the second command line, when you build the shared library. Any linker options you pass when compiling with -c are simply ignored.dmd -c dll.d -fPIC -L-ldl -L/usr/lib/x86_64-linux-gnu/libsqlite3.a dmd -oflibdll.so dll.o -shared -defaultlib=libphobos2.so -L-rpath=/root/dlangProjectsNo ability to access the C object. It does not even seem to be included based upon the file size.This works ( using the already existing shared sqlite3 object ) but i am just linking the sqlite3 to the shared object.So replace libsqlite3.so with the static library here.dmd -c dll.d -fPIC dmd -oflibdll.so dll.o -shared -defaultlib=libphobos2.so -L-rpath=/root/dlangProjects -L/usr/lib/x86_64-linux-gnu/libsqlite3.so
Dec 12 2016
On Monday, 12 December 2016 at 14:11:49 UTC, Mike Parker wrote:So replace libsqlite3.so with the static library here.See the 3th example in the original post.../usr/bin/ld: /usr/lib/x86_64-linux-gnu/libsqlite3.a(sqlite3.o): relocation R_X86_64_PC32 against symbol `sqlite3_strnicmp' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad valueFrom my understanding, because the libdll has a shared tag, the libsqlite3.a needs to be linked as static and the rest needs to be dynamic. I found some examples using Gcc ( static & dynamic flags ) but those do not work for DMD.
Dec 12 2016
On Monday, 12 December 2016 at 15:19:55 UTC, Benjiro wrotFrom my understanding, because the libdll has a shared tag, the libsqlite3.a needs to be linked as static and the rest needs to be dynamic. I found some examples using Gcc ( static & dynamic flags ) but those do not work for DMD.If you can't get DMD to pass the proper linker flags, you should still be able to call the linker manually. Or even pass the object files and libs along via gcc.
Dec 12 2016
On Monday, 12 December 2016 at 15:39:47 UTC, Mike Parker wrote:On Monday, 12 December 2016 at 15:19:55 UTC, Benjiro wrotThanks. Simply ended up linking to the shared library. Not what i had in mind but it works. It always takes time to figure things out ;)From my understanding, because the libdll has a shared tag, the libsqlite3.a needs to be linked as static and the rest needs to be dynamic. I found some examples using Gcc ( static & dynamic flags ) but those do not work for DMD.If you can't get DMD to pass the proper linker flags, you should still be able to call the linker manually. Or even pass the object files and libs along via gcc.
Dec 14 2016