C++DLL生成与调用

C++DLL生成与调用

生成DLL之前需要声明导出的接口函数;
C++DLL生成与调用_第1张图片

#define EDSCOMPOSITION_EXPORTS

#include "EDScomposition.h"
#include "parameters.h"
#include "NeutronEDSResolve.h"
#include "RrConfig.h"


//#include "pch.h"
#pragma warning(disable:4996)

//template
EDSCOMPOSITION_API int EDScomposition(string path, CMatrix* result, CMatrix* EDStestMaterial, CMatrix* TimetestMaterial)

调用DLL文件的方式
#include
#include
#include //使用函数和某些特殊变量
#include “CMatrix.h”
#include “EDScomposition.h”
#pragma comment(lib,“读配置文件.lib”)
#include

extern “C” __declspec(dllimport) int EDScomposition();

#pragma warning(disable:4996)

VS2019环境下C++动态链接库(DLL)的创建与调用
https://blog.csdn.net/qq_30139555/article/details/103621955

VS 配置类型为dll生成的lib可以自定义def文件代替,例如
LIBRARY
EXPORTS
EDScomposition=?EDScomposition@@YAHV? b a s i c s t r i n g @ D U ? basic_string@DU? basicstring@DU?char_traits@D@std@@V? a l l o c a t o r @ D @ 2 @ @ s t d @ @ P E A U ? allocator@D@2@@std@@PEAU? allocator@D@2@@std@@PEAU?CMatrix@N@@11@Z

cmd终端 在dll所在文件夹下 cd 使用指令dumpbin - EXPORT EDScomposition.dll查看其接口函数

你可能感兴趣的:(C++DLL生成与调用)