[Botan-devel] App crashes trying to load certificate (VC7, Windows XP)

Jack Lloyd lloyd at randombit.net
Mon Jun 6 12:58:46 EDT 2005


Well, first things first - does the test application build/run? Part of that
code involves doing some (fairly minimal) testing of the X.509 code. I think it
is likely that it will work just fine, VC7 seems to be quite capable compared
to earlier versions, but just in case...

What it looks like is that the standard C library that Botan linked against and
the standard C library that your application links against are different
versions - Windows has (IIRC) four variants: multiple threads, single threaded,
and debug versions of both of those. Everything has to link against the same
one or things get very confused, and that looks like what is happening here.

Probably the 'right' thing to do is rebuild Botan, modifying the makefile to
use the right flag so that Botan is built against the same version of the C
library as your application is - I believe the flags in question are /MD, /ML,
or /MT, but I don't know what the default is, or what your app is expecting, so
I can't tell you which one you should actually be using in this case.

Hope this helps,
  Jack

On Mon, Jun 06, 2005 at 11:07:22AM -0500, Ritwick Dhar wrote:
> Hello,
> 
> I'm a new Botan user - just trying to get a sample app to load a X509
> cert. Botan built fine using the config file and nmake, creating
> libbotan.lib. However, while trying to build my app, I get the
> following linker error:
> 
> --------------------------
> libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall
> std::_Lockit::_Lockit(int)" (??0_Lockit at std@@QAE at H@Z) already defined
> in libbotan.lib(pipe_io.obj)
> libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall
> std::_Lockit::~_Lockit(void)" (??1_Lockit at std@@QAE at XZ) already defined
> in libbotan.lib(pipe_io.obj)
> 
> --------------------------
> If I exclude the library libcpmtd.lib using the
> /NODEFAULTLIB:"libcpmtd.lib" option, I get a bunch of errors saying:
> ---------------------
> LIBC.lib(crt0dat.obj) : error LNK2005: ___crtExitProcess already
> defined in LIBCMT.lib(crt0dat.obj)
> LIBC.lib(crt0dat.obj) : error LNK2005: __cinit already defined in
> LIBCMT.lib(crt0dat.obj)
> LIBC.lib(crt0dat.obj) : error LNK2005: _exit already defined in
> LIBCMT.lib(crt0dat.obj)
> LIBC.lib(crt0dat.obj) : error LNK2005: __exit already defined in
> LIBCMT.lib(crt0dat.obj)
> LIBC.lib(crt0dat.obj) : error LNK2005: __cexit already defined in
> LIBCMT.lib(crt0dat.obj)
> ....
> -------------------
> 
> If I exclude both offending libraries with /NODEFAULTLIB:"libcpmt.lib"
>  and /NODEFAULTLIB:"libcmt.lib", the application builds, but crashes
> at runtime with an exception:
> ---------------------
> Object reference not set to an instance of an object.
>    at Botan.MemoryRegion<unsigned char>.__dtor(MemoryRegion<unsigned char>* )
>    at Botan.X509.load_key(basic_string<char,std::char_traits<char>,std::allocator<char>
> >* )
>    at main()
> --------------------
> The offending line is:
> 		X509_PublicKey* key = X509::load_key("d:\\documents\\workarea\\pubCert.pem");
> 
> 
> Any help is greatly appreciated.
> 
> Regards
> Rit
> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://www.randombit.net/mailman/listinfo/botan-devel



More information about the botan-devel mailing list