[botan-devel] Linker error on OS X 10.11.2

john skaller skaller at users.sourceforge.net
Tue Dec 29 16:30:56 EST 2015

> On 30 Dec 2015, at 01:41, Jack Lloyd <lloyd at randombit.net> wrote:
> Hi Sviatoslav,
> This error appears to be due to the recent addition of a call to a
> Darwin security framework call (in module darwin_secrandom). It looks
> like to call SecRandomCopyBytes you must reference the framework at
> link time also.

in program to library calls this is a standard requirement on
all platforms.

In library to library calls it is standard on Windows but not
Linux.  In this respect Linux is seriously broken. More precisely
the linker “ld” is broken. There is a linker switch to override
this behaviour and force the linker to enforce closure of
symbol linkage (as it does already for static linkage).

Unfortunately if you use this switch you may find you also have
to provide CRT startup libraries which makes the link command
particularly platform dependent.


Also: on OSX you link against a shared library at link time 
and it records the absolute pathname of the library. For both
libraries and programs using a dylib. At run time you can
use DYLD_LIBRARY_PATH to override the recorded library name.
[This may explain why you have to provide the library at link time]
If you link against a library in its final location, such as a system framework,
you do not need any DYLD_LIBRARY_PATH. In fact you probably don’t
even know where the library is!

however there is a gotcha, which affects my product and probably Botan too.
If you build a library A, then you build B which links against A, and then 
you install A and B, then B refers to the *development* version of A not
the installed version. I use DYLD_LIBRARY_PATH to fix this. But the
correct procedure is to build and install libraries one at a time.

john skaller
skaller at users.sourceforge.net

More information about the botan-devel mailing list