Hello,

I have a statically linked library, which I'd like to convert to dynamically linked one. For that I'd have to export symbols. My question is what symbols should I export in case of the interfaces. Here is an example

// ----- IA.h
// Interface class
class IA{
static IA* m_Singleton;
void int b() = 0;
};

#if defined(NONCLIENT_BUILD)
	#define EXPORT __declspec(dllexport)
#else
	#define EXPORT __declspec(dllimport)
#endif

// Function that instantiates implementation of IA
EXPORT boost::shared_ptr<IA> CreateA();
// ----- a.cpp, which will be in a.dll
#define NONCLIENT_BUILD
class A: public IA {
void int b() {return 1;}
};
// Implementation of the function for instantiation
EXPORT boost::shared_ptr<IA> CreateA(){return boost::shared_ptr<IA>(new A);}
// Should this be exported as well?
IA* IA:m_Singleton = NULL;
// ----- main.h
#include "IA.h"
main(int argc, char *argv[])
{
boost::shared_ptr<IA> a = CrateA();
return IA:m_Singleton->b();
}

As for me the only thing from a.dll is CreateA(), hence I think I need to export only that function. This means that I do not need to export IA class. Am I thinking correctly?

The next question is, what should I do if IA if I have static member IA*. Where should I instantiate the singleton? Should it be exported?

Thank you.

you can export the entire class. I don't know if you can export boost library classes like this or not:

_dllspec(_dllexport) class A
{
// blabla
};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.