一个项目的代码太多。我想把部分类的声明和实现封装到不同的动态库中去。
在使用的时候提供 声明(*.h)头文件和动态库。 动态库dll里面有代码的具体实现。一般导出类的过程 如下:
#ifdef TEST_EXPORTS
#define TEST_API __declspec(dllexport)
#else
#define TEST_API __declspec(dllimport)
#endif// This class is exported from the Dtsm.dll
class TEST_API CTest {
public:
CTest (void);
// TODO: add your methods here.
};
这个标志TEST_API 难道是必须写吗?为什么有的动态库使用的时候 没有看到?
除了def文件。还有什么其他办法,让用户感觉和本地实用的是一样的? 谢谢
在使用的时候提供 声明(*.h)头文件和动态库。 动态库dll里面有代码的具体实现。一般导出类的过程 如下:
#ifdef TEST_EXPORTS
#define TEST_API __declspec(dllexport)
#else
#define TEST_API __declspec(dllimport)
#endif// This class is exported from the Dtsm.dll
class TEST_API CTest {
public:
CTest (void);
// TODO: add your methods here.
};
这个标志TEST_API 难道是必须写吗?为什么有的动态库使用的时候 没有看到?
除了def文件。还有什么其他办法,让用户感觉和本地实用的是一样的? 谢谢
#define TEST_API __declspec(dllexport)
#else
#define TEST_API __declspec(dllimport)
#endif class TEST_API CTest
{
...........
};这是标准写法
#define TEST_API __declspec(dllexport)
#else
#define TEST_API __declspec(dllimport)
#endif
如果定义了TEST_EXPORTS
TEST_API 就代表导出,否则代表导入,这个头文件可以用到
输出端和输入端,一举两得!!
DESCRIPTION 'XanticKit Windows Dynamic Link Library'EXPORTS
; Explicit exports can go here
CloseFtpSession = _CloseFtpSession@4 @1 private
FtpSvrConnect = _FtpSvrConnect@24 @2 private
GetLastFtpResponse = _GetLastFtpResponse@12 @3 private
FtpCreateAutoAcitve = _FtpCreateAutoAcitve@8 @4 private
FtpCloseAutoActive = _FtpCloseAutoActive@16 @5 private
FtpChangeDir = _FtpChangeDir@16 @6 private
FtpGetFileSize = _FtpGetFileSize@20 @7 private
FtpList = _FtpList@20 @8 private
FtpCreateKernelTasks = _FtpCreateKernelTasks@36 @9 private
FtpInitSubTasks = _FtpInitSubTasks@24 @10 private
一个*.def例子