0

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;    
};
xaxxon
  • 19,189
  • 5
  • 50
  • 80
Habib
  • 41
  • 7
  • The error says _"I cannot find implementation of `MikrotikAPI`'s default constructor"_. It has nothing to do with `dllexport`. – zdf Apr 27 '16 at 11:15
  • Thanks ZDF, you are right. How could not i see it. It works perfectly now. – Habib Apr 27 '16 at 12:17

0 Answers0