can i create Dll with VC++ 2008 and use it in VC++ 6?

后端 未结 2 755
情歌与酒
情歌与酒 2021-01-25 10:11

I have made a DLL with VC++ 2008 and when i use it in console application VC++ 6.0, there is an exception:

(msvcr90.dll): 0xc0000005: Access Violation

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-25 10:29

    If you want to build a DLL with Visual C++ version X and use it in Visual C++ version Y, you have some options:

    1. Build a DLL which exposes a pure C interface. You can use C++ inside the DLL, but the public interface must be pure C (so, for example, you can't throw exceptions crossing DLL boundaries).
    2. Build a COM DLL (possibly with the help of tools like ATL).
    3. Build a DLL using COM-like techniques, i.e. expose only abstract interfaces and factory functions from your DLL (this technique is explained in this article on CodeProject "HowTo: Export C++ classes from a DLL", in particular in the paragraph "C++ Mature Approach: Using an Abstract Interface").

    It is also important to point out that the code which allocates memory and the code which frees memory must use the same allocator.

提交回复
热议问题