[botan-devel] DLL_BOTAN

john skaller skaller at users.sourceforge.net
Sat Jan 26 10:19:45 EST 2013

Botan has a macro DLL_BOTAN set to support Windows DLL builds.
It's inconsistent where it puts it:


src/utils/charset.h:bool BOTAN_DLL is_digit(char c);


src/utils/parsing.h:BOTAN_DLL u32bit to_u32bit(const std::string& str);

On OSX this macro is set to:

#ifndef BOTAN_DLL
  #define BOTAN_DLL __attribute__((visibility("default")))

in build/build/h by:

src/build-data/buildh.in:  #define BOTAN_DLL %{visibility_attribute}

[It seems to work but I see no point specifying it on unix platforms,
why introduce a non-standard feature?]

I think (not sure) build.h gets included in everything.

I'm not sure how this can work. My guess is that on Windows:

#define BOTAN_DLL __declspec(dllimport)

and the idea is to override on the command line, when building a DLL,
however there's no way to specify a value for a macro on the command line
AFAIK. So you'd need two build.h files, one for use and a secret one just
for building.
My build system does it like this:

#if !defined(FLX_STATIC_LINK) && FLX_WIN32
#define FLX_EXPORT __declspec(dllexport)
#define FLX_IMPORT __declspec(dllimport)
#define FLX_EXPORT
#define FLX_IMPORT


which is sensitive to 3 macros:

FLX_WIN32 which is based on MSC_VER or whatever.
FLX_STATIC_LINK which is set on the command line for static linkage on any platform 
BUILD_BOTAN which is set on the command line when building BOTAN into  shared library on any platform

This only requires -DMACRO_NAME without a value, and the specification
is platform independent.

john skaller
skaller at users.sourceforge.net

More information about the botan-devel mailing list