Question

Juan Dent on Fri, 28 Jul 2017 19:31:58


Hi,

I have the source for a static lib but for some reason it does not allowed configuring as dynamic lib (DLL). My app is an MFC with runtime multi-threaded DLLs and so linking throws a lot of errors.

What can I do to make this static lib work with my MFC app?

The REAL issue here is that some libraries cannot be built dynamically, so how can I use them in a user interface MFC app? Here the library in question is crytopp which I installed with vcpkg.exe and it says it cannot be built DLL...

Thanks,

Juan 


Juan Dent



Sponsored



Replies

RLWA32 on Fri, 28 Jul 2017 20:16:35


If you wanted to use a DLL the general approach would be to create a wrapper DLL for the static library.

Juan Dent on Fri, 28 Jul 2017 20:19:42


But how? How could one create a DLL that links statically to the cryptopp library? Won't I get all the errors? What do you mean "wrapper DLL"? Could you please explain a bit?

Regards,

Juan Dent


Juan Dent


RLWA32 on Fri, 28 Jul 2017 20:23:54


The wrapper DLL would link with the static library and export functions that would be forwarded to the corresponding functions in the static library.  For example,

__declspec(dllexport) int DLL_Func()

{

        return StaticLib_Func()

}


Juan Dent on Fri, 28 Jul 2017 20:27:35


But the wrapper DLL would use DLL runtime library so the same issue would occur as when I try to use the cryptopp library from the MFC app? I get what you say about the wrapper - that's great... But how will I link the DLL to the static library and then have MFC app link to this DLL? Won't runtime libraries conflict again?

Regards,

Juan Dent

RLWA32 on Fri, 28 Jul 2017 20:32:08


I have no idea what the runtime library requirements are for the cryptopp static lib.  Does it require the static CRT?  As far as I know there is no general requirement that a static library must link to the static CRT. 

RLWA32 on Fri, 28 Jul 2017 20:34:02


I suppose problems could arise depending on usage and what gets passed across DLL/CRT boundaries.  That's an implementation detail that I can't address.

Juan Dent on Fri, 28 Jul 2017 20:34:55


when I try compiling I get:

1>cryptlib.lib(cryptlib.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in RSAEncryptor.obj

RLWA32 on Fri, 28 Jul 2017 20:52:39


Can you build the static cryptopp library to use the CRT DLLs?

Juan Dent on Fri, 28 Jul 2017 21:06:20


Thanks for the suggestion --- actually I have to leave and can't do it, but will get back at you.

Thanks for your suggestions!!

Regards,

Juan

Sera Yu on Thu, 03 Aug 2017 10:52:29


Hi Juan Dent,

thanks for posting here.

Have your case been solved? If it has, please help to mark answer. If you have any other concerns, just feel free to contact us.

Your understanding and cooperation will be grateful.

Best Regards,
Sera Yu