0

I found a IPC Library online which after compiling it will become ".lib", so i tried converting it to DLL instead of using .lib, but after declaring exports on the features i need to export the VS Express compiler gave a warning stated

'PipeTransport::buf_': class 'std::vector>' needs > to have dll-interface to be used by clients of class

The EXPORT definition

#define EXPORT __declspec(dllexport)

This is the code exported...

class EXPORT PipeTransport : public PipeWin {
public:
  static const size_t kBufferSz = 4096;

  size_t Send(const void* buf, size_t sz) {
    return Write(buf, sz) ? ipc::RcOK : ipc::RcErrTransportWrite;
  }

  char* Receive(size_t* size);

private:
  IPCCharVector buf_;//The Line giving error
};

The Library link is here

The Header file giving error is here

I read this , but can't get it to work coz i don't understand much of it as i'm new to C++(Totally noob).

Community
  • 1
  • 1
Joe Does
  • 1
  • 3
  • The answer is returned in the first result if you google your error. Why do we have to google something for you? – SergeyA Oct 09 '15 at 18:52
  • Maybe it showed that result in your location, Google didn't show this here to me... And, thanks for the Suggestion... That was exactly what i wanted to know how to do... Insantiating a class... Thanks once again – Joe Does Oct 09 '15 at 19:00

1 Answers1

-1

The C way to export a class object will be like that but I don't know how to export class in DLL

Here your DLL
class AbstractClass
{
public:
    virtual void somefunction() = 0;
}

//Inherite from this class
class MyClass : public AbstractClass
{
    virtual void somefucntion(){/*implement*/}
}

//Create your export object
MyClass* myObject = NULL;

//Create some EXPORT define to make it easy when you declare function
#define EXPORT_DLL __declspec(dllexport)

//Declare function
extern "C" EXPORT_DLL void* myExportedFunction ();

//Implement
EXPORT_DLL void* myExportedFunction ()
{
    if(myObject == NULL)
        myObject = new MyClass();
    return myObject;
}

And now from exterior of your function you can call this function like that. Sure you need to load your dll, your function and other things, here i just pass these step and show you only how to use this code.

//You must have a declaration of your abstract class in exterior of dll
AbstractClass* dllObjet = NULL;

dllObject = myExportedFunction()

//And now you can use it
dllObject->somefucntion();
Captain Wise
  • 480
  • 3
  • 13
  • Wrong. You can have classess exported out of DLLs. – SergeyA Oct 09 '15 at 19:02
  • Oh my bad, i always thinked that it was not possible, and i looked at google and you are right, sorry for that, I modify my answer – Captain Wise Oct 09 '15 at 19:05
  • What about if i don't need the classes? Should i follow this method to simplify the function name instead of all this :: Class bits? – Joe Does Oct 09 '15 at 20:48