testdll.h文件
#ifndef TESTDLL_H
#define TESTDLL_H
#ifdef DLL_EXPORT
#define TEST_API extern "C" __declspec(dllexport)
#else
#define TEST_API extern "C" __declspec(dllimport)
#endif
TEST_API void testfunc();
#endif
testdll.cpp文件
#define DLL_EXPORT
#include "testdll.h"
#include <iostream>
#include <string>
using namespace std;
void testfunc()
{
string s1 = "test string";
cout << s1 << endl;
}
这样在命令行下通过下面的命令
dumpbin /exports testdll.dll
就可以看到导出的函数了。
上面的__declspec(dllexport)用于生成lib文件,extern "C"是防止C++编译器名字改编。
注意.c文件中不能使用extern “C”
本文地址:https://blog.csdn.net/csdn_gddf102384398/article/details/107375775
如对本文有疑问, 点击进行留言回复!!
APP调用微信小程序,能拉起小程序,但是onResp回调不会被调用问题
Codeforces Round #657 (Div. 2) B. Dubious Cyrpto(思维,数学)
网友评论