问题如下:
建立dll项目后,在Api_Head.hpp头文件中,定义宏:
#ifndef API_HEAD_HPP #define API_HEAD_HPP
#ifdef API_DLL_COMPILATION
#define API_IMPORT_EXPORT __declspec(dllexport)
#else
#define API_IMPORT_EXPORT __declspec(dllimport)
#endif
class API_IMPORT_EXPORT CServerControl {
public:
static void init();
int fun();
private:
static std::map<const uint8_t, std::shared_ptr<IHelp>> mControl;
static std::mutex mControlMutx;
};
#endif
Api_Head.cpp中的定义如下:
#define API_DLL_COMPILATION(很重要)
#include “Api_Head.hpp”
std::map<const uint8_t, std::shared_ptr<IHelp>> mControl;
std::mutex mControlMutx;
在进行编译过程中mControl,与mControlMutx同时报错如下: