本人菜鸟一枚,本篇文章只为自己做个记录。
//test.h
#pragma once
#if defined (EXPORTBUILD)
# define _DLLExport __declspec (dllexport)
# else
# define _DLLExport __declspec (dllimport)
#endif
extern "C" int _DLLExport MyADD(int x, int y);
extern "C" int _DLLExport GetIsRightTime();
extern "C" char _DLLExport *GetString();
//test.cpp
//宏定义
#define EXPORTBUILD
//加载头文件
#include "Test.h"
#include <time.h>
#include <iostream>
#include <stdlib.h>
//设置函数
int _DLLExport MyADD(int x, int y)
{
return x + y;
}
int _DLLExport GetIsRightTime()
{
time_t tt = time(NULL);
tm* t = localtime(&tt);
return t->tm_mon+1;
};
char _DLLExport *GetString()
{
char* str = "aaa";
return str;
}
参考链接:http://blog.csdn.net/qcontriver/article/details/9455481
http://www.cnblogs.com/equation/articles/6560451.html
http://wangqingpei557.blog.51cto.com/1009349/595015