Building .dll for lower version of visual studio

I am using Visual Studio 2010 to create a DLL.

And another programmer who uses Visual Studio 2005 wants to use my DLL. It can compile with my dll, but when the application starts, it just crashes with the exception of bad_alloc. I guess because of a different version of CRT.

When creating my DLL, I tried both dynamic CRT (/ MD) binding and static CRT (/ MT) binding, but both failed.

So, can I create a DLL that can be used by a lower version of visual studio? If not, how can I do this?

+3
source share
6 answers

, dll-. memmory , , , . .

:

extern "C" __declspec(dllexport) void doSomething(int input);
+3

: DLL DLL CRT. ( , DLL V++ 2005), V++ 2005, V++ 2010.

+3
+3

VS2005, Platform Toolset VS2010 VS2005.

Project PropertiesGeneralPlatform Toolset. VS100 - vs2010, VS90 2008 ( ) VS80 - , ( 2005...).

AFAIK, DLL-, , ( , ).

+2

, (, ++), V++, DLL DLL, V++, , .

DLL (V++ 8.0 VS2005, V++ 9.0 2008, V++ 10.0 2010...), . Visual Studio, , .

+1

, COM. :

  • (aka interface) (, IExportedFunctionality), , (, CExportedClass), .
  • CExportedClass .
  • CExportedClass IExportedFunctionality .
  • 2 Dll

    a. GetExportedClass which returns a pointer to a new instance of CExportedClass upcast to IExportedFunctionality*.
    b. FreeExportedClass which accepts a IExportedFunctionality* and deletes it.
    

IExportedFunctionality. lib, LoadLibrary GetProcAddress GetExportedClass FreeExportedClass.

. IExportedFunctionality

  • - IExportedFunctionality - , .
  • A pure virtual destructor - so doing a delete in IExportedFunctionality * will translate into a call to the CExportedClass destructor
  • They do not have ANY data elements in IExportedFunctionality (since user383522 indicated that the binary layout of a class may vary in different compilers and under different byte alignments)
0
source

All Articles