码迷,mamicode.com
首页 > 其他好文 > 详细

动态链接库的生成与调用

时间:2014-11-01 17:53:09      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:blog   http   ar   sp   文件   on   2014   log   size   

bubuko.com,布布扣

点击解决方案中的项目,右键属性,常规配置类型选择DLL

//.h文件
#include<stdlib.h>
extern "C" __declspec(dllexport) int __stdcall funs(int a,int b);
 

<pre name="code" class="cpp"><pre name="code" class="cpp">//.cpp文件


#include "DLL.h"
extern "C" __declspec(dllexport) int __stdcall funs(int a,int b)
{
	printf("%d %d",a,b);
	return a+b;
}
<pre name="code" class="cpp">//调用方法
#include "DLL.h"
#include <string>
#pragma comment (lib,"BBCC.lib")

int main()
{
	int a = funs(12,65);
	
	getchar();
	return 0;
}

如果不成功就把
<pre name="code" class="cpp">extern "C"

去掉





动态链接库的生成与调用

标签:blog   http   ar   sp   文件   on   2014   log   size   

原文地址:http://blog.csdn.net/u012454516/article/details/40681811

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!