Waldek Hebisch wrote:
Adriaan van Os wrote:
Waldek Hebisch wrote:
<snip>
Note: to make shared library one needs shared libgpc.
Why ?
If you intend to use at most one shared library in a program then it is enough to use -fPIC (and for example i386 does not even require -fPIC).
And -fPIC is the default on some platforms.
However, if you use multiple shared libraries and static libgpc, then each shared library will bring its own copy of libgpc. In particular there will be two copies of libgpc data. Depending on dynamic linker you will get dynamic link errors or subtle errors at runtime.
Unless global symbols from libgpc are marked as non-global in the shared library, e.g.
[G5:~] adriaan% gp --compile-and-link MainUnit.pas -dynamiclib -Wl,-init,_MyDylibInit -Wl,-install_name,@executable_path/MyDylib -o MyDylib -Wl,-exported_symbols_list,Symbols.txt
where Symbols.txt is the list of symbols that we want export from the shared library
[G5:~] adriaan% cat Symbols.txt _MyDylibInit _MyDylibTest
Regards,
Adriaan van Os