
调用Dll的工程遇到应用程序正常初始化(0xc000000d)失败。请单击“确定”,终止应用程序。
我的开发环境是Win32 XP,VS2010
最终找到原因,之前使用的是Debug模式,应该使用Release来编译生成Dll,使用才不会出错,特此记录整个配置过程以备忘,折腾免疫HOHO~:
1、新建Win32工程,选择Dll,工程名叫MyDll
2、添加Header Files:testdll.h,内容如下:
#ifndef TestDll_H_
#define TestDll_H_
#ifdef MYDLL_EXPORTS
#define MYLIBDLL extern "C" _declspec(dllexport)
#else
#define MYLIBDLL extern "C" _declspec(dllimport)
#endif
extern "C"
{
MYLIBDLL int Add(int plus1, int plus2);
};
#endif
3、添加Source Files:testdll.cpp,内容如下:
#include "stdafx.h"
#include "testdll.h"
#include <iostream>
using namespace std;
int Add(int plus1, int plus2)
{
int add_result = plus1 + plus2;
return add_result;
}
4、选

本文记录了在Win32 XP环境下,使用VS2010创建DLL时遇到的应用程序初始化失败问题及解决方案。问题在于使用Debug模式,而应使用Release模式编译DLL。步骤包括新建Win32工程,配置Header Files,编译生成.lib和.dll文件,并在另一个Win32 Console工程中设置额外的Include和Library目录,确保.lib和.dll文件的正确引用。
最低0.47元/天 解锁文章
5231





