1. 修改MyDLL
MyDLL.h
#pragma once
#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif
using namespace std;
class MYDLL_API ADD_Control {
public:
ADD_Control();
int ADD(int i,int j);
private:
int ADD_ID = 0;
};
MyDLL.cpp
#include "pch.h"
#include <cmath>
#include <iostream>
#include "MyDLL.h"
ADD_Control::ADD_Control()
{
std::cout << "Hello ADD";
}
int ADD_Control::ADD(int i, int j)
{
return i + j;
}
2. 在讀入的控制APP加入定義宏
3. 測試看看結果
#include <iostream>
#include "MyDLL.h"
int main()
{
ADD_Control Add_test;
std::cout << "test: "<< Add_test.ADD(5,6) << "\n";
std::cout << "Hello World!\n";
std::cin.get();
}