Thread overview
Creating a dynamic library
Sep 30, 2017
Tony
Sep 30, 2017
Elronnd
Sep 30, 2017
Tony
Sep 30, 2017
Mike Wey
Sep 30, 2017
Tony
September 30, 2017
I would like to know that command line (I am on Linux) I would use to compile a D file and create an object file that is suitable for a Linux dynamic library (.so).

I believe it is probably

dmd -c -fPIC my_file.d

Also, what is the command line to create a dynamic library from one or more object files that have been compiled for dynamic invocation?

dmd ??? -shared ???
	
September 30, 2017
dmd bla.d bla2.d -shared -fPIC -oflibbla.so
September 30, 2017
On Saturday, 30 September 2017 at 01:02:08 UTC, Elronnd wrote:
> dmd bla.d bla2.d -shared -fPIC -oflibbla.so

Thanks. I don't normally compile right into a .so, but I think this is OK:

dmd my_file.o my_other_file.o  -shared   -of=libutest.so


One thing I picked up from SCons is creating dynamic object files with a .os extension and static object files with the standard .o extension. That way they can be compiled in the same directory in the same build step. But dmd rejects the files that are named *.os. Is there an extension besides .o that dmd would accept for the dynamic object files?


September 30, 2017
On 30-09-17 03:27, Tony wrote:
> One thing I picked up from SCons is creating dynamic object files with a .os extension and static object files with the standard .o extension. That way they can be compiled in the same directory in the same build step. But dmd rejects the files that are named *.os. Is there an extension besides .o that dmd would accept for the dynamic object files?

I've been using .pic.o so it still ends with .o for dmd.

-- 
Mike Wey
September 30, 2017
On Saturday, 30 September 2017 at 10:09:43 UTC, Mike Wey wrote:
> On 30-09-17 03:27, Tony wrote:
>> One thing I picked up from SCons is creating dynamic object files with a .os extension and static object files with the standard .o extension. That way they can be compiled in the same directory in the same build step. But dmd rejects the files that are named *.os. Is there an extension besides .o that dmd would accept for the dynamic object files?
>
> I've been using .pic.o so it still ends with .o for dmd.

Thanks for the suggestion!

I was thinking that this might be a linker function only and tried to use g++ and gcc for the .so creation but, while they both create the same size file as each other, it is different than what dmd does when called with -shared.