Question about shared library (DLL) export & import

A

Allen

I write 3 classes:

class CRPCParaPacker
{
private:
CRPCInParaPacker inPack;
CRPCOutParaPacker outPack;
};

I want to export only CRPCParaPacker class. So in the header file of
CRPCParaPacker, I use
#ifdef WIN32
#ifdef RPCPACKER_EXPORTS
#define RPCPACKER_API __declspec(dllexport)
#else
#define RPCPACKER_API __declspec(dllimport)
#endif

#ifndef RPCPACKER_EXPORTS
#pragma comment(lib, "RPCPacker.lib")
#pragma message("Automatically linking with RPCPacker.dll")
#endif
#pragma warning(disable : 4251)
#endif

class CRPCInParaPacker;
class CRPCOutParaPacker;

class RPCPACKER_EXPORTS CRPCParaPacker
{
private:
CRPCInParaPacker inPack;
CRPCOutParaPacker outPack;
};

Class CRPCInParaPacker and CRPCOutParaPacker are not exported.

When compile above classes into DLL, it is ok.
But when used in other application, it is compiled with errors:

rpcparapacker.h(190) : error C2079: "CRPCParaPacker::inPacker" uses
undefined class"CRPCInParaPacker"
rpcparapacker.h(190) : error C2079: "CRPCParaPacker::eek:utPacker" uses
undefined class"CRPCOutParaPacker"

Why?
 
I

Ian Collins

Allen said:
I write 3 classes:

class CRPCParaPacker
{
private:
CRPCInParaPacker inPack;
CRPCOutParaPacker outPack;
};

I want to export only CRPCParaPacker class. So in the header file of
CRPCParaPacker, I use
#ifdef WIN32

You've come to the wrong place, try a windows group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top