zhfuliang

DLL函数导出方式有多种方式,这里介绍的是其中一种方式

头文件:

#ifndef _GPTSQLITE_H__
#define _GPTSQLITE_H__

#ifdef __cplusplus
extern "C" {
#endif

#ifdef _EXPORTING
#define CLASS_DECLSPEC __declspec(dllexport)
#else
#define CLASS_DECLSPEC __declspec(dllimport)
#endif

CLASS_DECLSPEC int Add(int i, int j);

#undef _DLL_GPTSQLITE

#ifdef __cplusplus
}
#endif

#endif

 源文件

#include "StdAfx.h"
#define _EXPORTING

#include "gptsqlite.h"

CLASS_DECLSPEC int Add(int i, int j)
{
	return i+j;
}

  调用函数

#include "stdafx.h"
#include<cstdlib>
#include <iostream>
#include "../dlldatabase/gptsqlite.h"
#pragma comment(lib, "dlldatabase.lib")
int _tmain(int argc, _TCHAR* argv[])
{
	int i = Add(1, 2);
	std::cout << i << std::endl;
	system ("pause");
	return 0;
}

  

分类:

技术点:

相关文章:

  • 2021-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-12-23
  • 2021-12-14
  • 2021-12-23
  • 2021-12-23
猜你喜欢
  • 2021-10-15
  • 2021-12-23
  • 2021-12-23
  • 2021-12-23
  • 2021-12-23
  • 2021-08-28
  • 2021-11-21
相关资源
相似解决方案