[Botan-devel] DLL builds, ELF visibility, split shared/static builds

Jack Lloyd lloyd at randombit.net
Mon Apr 21 13:06:47 EDT 2008

Joel Low contributed some patches that add a new macro BOTAN_DLL that
annotates which symbols/classes should be exported from a shared
object. This is required for Windows/Visual Studio DLL builds, because
by default all symbols are hidden, with only those explicitly
qualified being exported to callers. This is very different from the
Unix default, which is for all symbols to be visible unless otherwise

I have not been able to test it yet on VC (and probably a problem or
three remains in there), however I did test using GCC. While by
default GCC uses the export-everything rule, this can be changed (in
GCC >= 4.0) by using -fvisibility=hidden (changing the default symbol
visibility to local to the shared object) along with the visible
attribute on specific symbols: nicely, this attribute was set up to be
semantically equivalent to the Visual Studio directive that controls
DLL symbol export.

I am hoping to make this the new default for Unix GCC .so builds,
since it provides many benefits as mentioned in
though currently I still have concerns about some level of broken-ness
with exception typeinfo, as mentioned in the 'Problems with C++
exceptions' section of the GCC wiki page (I have yet to look at/test

One change I am planning on making soon(-ish) is splitting the build
up, one half for static and the other for shared with totally
different options, .o files, build.h, etc. That will allow the static
lib to be compiled sans -fPIC, etc, and the shared to have the right
visibility attributes, etc set.


More information about the botan-devel mailing list