Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building .dll for lower version of visual studio

I'm using Visual Studio 2010 to build my DLL library.

And, other programmer who's using Visual Studio 2005 wants to use my DLL library. He can compile with my dll, but, when running his application, it just crashes with bad_alloc exception. I assume that's because of different CRT version.

When building my DLL library, I tried both dynamic linking of CRT(/MD) and static linking of CRT(/MT), but both failed.

So, can't I make DLL library that can be used by lower version of visual studio? If not, how I can I do that?

like image 504
Daniel K. Avatar asked Oct 21 '25 14:10

Daniel K.


1 Answers

As far as I know you have to use only primitive types dll interface. it's because even in a same compiler memmory layout changes by only changeing compile flags, think of what would happen by changing compiler. and that could lead to a largescale undifined behavior.

and use the following format for your function interfaces:

extern "C" __declspec(dllexport) void doSomething(int input);
like image 96
Ali1S232 Avatar answered Oct 23 '25 04:10

Ali1S232



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!