What is the best way to write code for foreign functions which may be absent (removed / renamed)?
OpenSSL often renames functions, even the function which returns OpenSSL version number is renamed from SSLeay to OpenSSL_version_num.
Code like this:
(ignore-errors (cffi:defcfun ("SSL_CTX_set_default_verify_dir" ssl-ctx-set-default-verify-dir) :int (ctx :pointer)))
fails despite ignore-errors if the foreign function is absent (the libssl.so version loaded doesn't have it).
It fails when the fasl file containing this code is loaded:
KERNEL:SIMPLE-PROGRAM-ERROR: Undefined foreign symbol: "SSL_CTX_set_default_verify_dir"
The same failure even if we modify the code this way:
(when nil (cffi:defcfun ("SSL_CTX_set_default_verify_dir" ssl-ctx-set-default-verify-dir) :int (ctx :pointer)))
Is there a way to not fail when the function is absent? Preferably such that supports saving and loading lisp image, probably with another version of the foreign library, where different sets of functions are removed / added.