Creating a shared library under Linux?

Mike Wey mike-wey at example.com
Sun Jul 29 06:55:25 PDT 2012


On 07/29/2012 02:34 PM, Jens Mueller wrote:
> Mike Wey wrote:
>> I've successfully build GtkD as a shared library using LDC using the
>> following steps:
>>
>> Compiling the source files with fPIC:
>> ldc -O -m64 -relocation-model=pic -Isrc -c (source file)
>>
>> Combine all the GtkD object file into one big object file:
>> ld -r (all GtkD object files) -o output.o
>>
>> Create the shared lib using LDC:
>> ldc -shared output.so -L-soname=(so version) output.o
>
> Thanks a lot.
> This does work if the last command is changed to
> ldc2 -shared -of=output.so -L-soname=1 output.o
> and ldc was built using -DBUILD_SHARED_LIBS=ON.
>
> Jens
>


I looks like i didn't get the soname quite right, it should have been:
ldc -shared output.so -L-soname=output.so.(so version) output.o


the soname is the name of the library ld will try to load at program 
startup. if you are not going to use to typical linux approach of 
setting up symlinks to get both a versioned and a unversioned lib in the 
filesystem. Then you don't have to specify a somane as the default 
soname is the name of the lib.

-- 
Mike Wey




More information about the Digitalmars-d mailing list