I use it his way (with wxWidgets):
#ifdef __cplusplus
extern "C"
{
#endif // #ifdef __cplusplus
#ifdef __WXMSW__
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else // #ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllimport)
#endif // #ifdef BUILD_DLL
#else // #ifdef __WXMSW__
#define DLL_EXPORT
#endif // #ifdef __WXMSW__
class DLL_EXPORT foo {
public:
foo();
~foo()
};
#ifdef __cplusplus
}
#endif // #ifdef __cplusplus
As far as I know, you can use your dll without explicitely exporting or importing (even on windows), if you only use it with MinGW/gcc, but I'm not absolutely sure about this.