[botan-devel] Build in VisualStudio Fails along with warnings "non dll interface class" and see declaration of 'Botan::Pipe::Invalid_Message_Number'

john skaller skaller at users.sourceforge.net
Tue Nov 19 03:34:22 EST 2013

On 19/11/2013, at 6:19 PM, Sitaraman Vilayannur wrote:

> Hi John,
>  I did look at that earlier, and it says for now I can ignore the warnings, but the build still fails for other reasons? Would I have to modify the example files? Thanks
> Sitaraman

Well I have no idea because you didn't post any log information related to the
actual failure.

I would guess there are actually serious consequences if this warning occurs.
This is all a bit C++ centric but: g++ had this problem. When you chuck an
exception and try to catch it, you have to look at the RTTI to see if the type
of the exception and your catch handler match.

Originally gcc just compared the pointers to the RTTI, or something similar.
But this does not work, because every shared library catching or throwing
an exception of a type defined in that library will have a distinct RTTI record.
As well as distinct vtables. And the same function instantiated in several
places will have distinct addresses.

There is no way around this in C++ in general. If it is to work properly
it is essential all shared entities are in a DLL and the clients are linked
to that DLL, so there is only ever ONE copy.

It is impossible to do enforce this in any sane way with templates.
[There is an insane way: every exported template instance gets
its own DLL so there cannot be more than one copy of anything]

I do not know what gcc people did but they fixed this problem, presumably
by changing the way run time types are compared: instead of comparing
pointers, compare some hash or mangled name or something.

In any case, the problem should be clear: there's a chance your will
make a Botan exception with a standard library base, but the exception
isn't derived from the base from the point of view of a foreign exception
handler, because the base has a vtable and RTTI only known in Botan
or your code.

Anyhow thats why the warning is there, it is in fact a hard error,
it means throwing and catching exceptions across DLL boundaries
may not work.

However in your case, I cannot see WHY you would get this error.
It indicates you're static linking the C++ library, which you must
never do on Windows.

Windows is a bit tricky. Normally a *.lib file is statically linked.
Cygwin at least calls export file *.exp or *.imp or something.

However on Windows, you have to understand there is no dynamic
linkage at all. Linkage is ALWAYS static. What actually happens is 
if you want dynamic linkage you do not link to the library static
archive, but instead to a thunk library. When you call a thunked function
it invokes the dynamic linker to find the DLL and the actual function
you wanted to call.

SO .. in your list of dependencies:


I really cannot tell if these *.lib static link libraries are actual static link libraries
or just thunks. I'm pretty sure the windows ones like kernel32.lib are thunks.

So, its very hard to tell how you managed to static link an actual library which
had a non-exported std::exception class in it.

If you actually did that a lot of things might fail at run time, and quite probably
during the build as well. But the problem you're having could be entirely 
unrelated :)

john skaller
skaller at users.sourceforge.net

More information about the botan-devel mailing list