I want to export a class from dll. If I put MIKROTIK_API (_declspec(dllexport) in front of the class name, I get a linking error. Without MIKROTIK_API , it compiles correctly.
I have put _Exporting in the preprocessor definition of the project. I am using visual studio to compile.
Error: MikrotikFace.obj : error LNK2019: unresolved external symbol "public: __thiscall MikrotikAPI::MikrotikAPI(void)" (??0MikrotikAPI@@QAE@XZ) referenced in function "public: __thiscall MikrotikFace::MikrotikFace(void)" (??0MikrotikFace@@QAE@XZ)
Two main files: MikrotikAPI.h (where class MikrotikAPI resides whos function i want to use) MikrotikFace.h (where I export class from dll)
MikrotikFace.h
#include"MikrotikAPI.h"
Macro definition:
#ifdef _Exporting
#define MIKROTIK_API __declspec( dllexport )
#else
#define MIKROTIK_API __declspec( dllimport )
#endif
Exporting class MikrotikFace:
class MIKROTIK_API MikrotikFace
{
public:
MikrotikFace(){;}
~MikrotikFace(){;}
// external functions
int LoginToMKT(const std::string &strUsername, const std::string &strPassword,
const std::string &strPort, const std::string &strIPAddr, int &nmerMKTErrorResult);
private:
MikrotikAPI m_mktMikrotikAPI;
};