convert a static library to a dynamic one?
Rainer Müller
raimue at macports.org
Sun Nov 18 21:37:02 UTC 2018
On 18.11.18 20:36, Mark Brethen wrote:
> The spooles src creates a static ‘spooles.a’ library. I want to get a dynamic library out of it. In BSD, for a .so library you would use:
>
> ld -Bshareable -o libspooles.so.1 -x -soname libspooles.so.1 --whole-archive spooles.a
>
> For macports I tried
>
> system -W ${worksrcpath}_SHARED ld -dylib -force_load spooles.a -o libspooles.1.dylib
>
> ld fails with an error:
>
> :info:build ld: symbol(s) not found for inferred architecture x86_64
> :info:build Command failed: ld -dylib -force_load spooles.a -o libspooles.1.dylib
> :info:build Exit code: 1
> :error:build Failed to build spooles: command execution failed
>
> How do I have to modify above command so I will get the desired result?
I would have extracted the object files from the archive and created a
dynamic library using libtool (that is /usr/bin/libtool, not to be
confused with GNU libtool).
ar -x spooles.a
libtool -dynamic *.o -o libspooles.1.dylib
You most likely should also set additional arguments such as
-install_name and -compatibility_version/-current_version if you want to
distribute the result in a port.
HTH,
Rainer
More information about the macports-dev
mailing list