C++编写动态链接库dll

新建项目,选择Visual C++下的Windows桌面程序,选择动态链接库程序,设置保存路径和文件名,默认会生成一些文件,包括预编译头文件。

  • 不带头文件
// ImageMosaic.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"

// 这里编写主要函数,即在外部调用dll时要引用的函数
 extern "C" _declspec (dllexport) void ImageUnit(int *data, int M, int N, int num)​
{

}​

    编译项目即可,右键项目,Build,即可在Debug目录里生成lib和dll文件。

  • 带头文件

    新建h文件:右键项目,Add一个h文件:

#pragma once
#ifndef SCM_H   // 匹配h文件名
#define SCM_H

extern "C"
{
	_declspec(dllexport) void invSIRT(float **TArray, float MeaAmp[], int iters, float x[]);

	_declspec(dllexport) void invSVD(float **TArray, float MeaAmp[], float lemt, int iters, float x[]);

	_declspec(dllexport) void invCG(float **TArray, float MeaAmp[], int iters, float x[]);
}

#endif

    在cpp文件里引用刚才Add的头文件,将头文件里的文件全部实现。

// SCM_Method.cpp : 定义 DLL 应用程序的导出函数。
//

#include "stdafx.h"
#include "SCM.h"


void invSIRT(float **TArray, float MeaAmp[], int iters, float x[]) 
{

}

void invSVD(float **TArray, float MeaAmp[], float lemt, int iters, float x[])
{

}

void invCG(float **TArray, float MeaAmp[], int iters, float x[])
{

}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值