Re: [gtkmm] gtkmm-2.4 on MSVC



Hello!

A few weeks ago I set out to reach a similar goal, but to my shame the attempt petered. The reason was that fixing the linking problems required a dllimport/dllexport to be added in front of all class declarations (in the .hg and .ccg files to keep those changes), plus some other places, namely statically declared functions in .ccg files and all global objects, which should keep their 'extern' specifier in their declaration. Well, I tried to disentangle the m4 macro files but didn't have enough time to pursue.

Maybe as explanation for Murray: To build a shared library under MSVC
(dll) you need to specify the exported classes, variables and functions. This is done with a special keyword (__declspec). You need to difference between import and export, e.g. if you compile the dll you must write __declspec(dllexport), if you use the dll you need to write __declspec(dllimport).

Practical you do something like that:

In a global header you define:

#ifdef WIN32
# ifdef GTKMM_DLL
#  define WINDLL_GTKMM __declspec(dllexport)
# else
#  define WINDLL_GTKMM __declspec(dllimport)
# endif
#endif

And then you write a class definition:

class WINDLL_GTKMM dll_exported_class
{
   ...
};

An exported function:

/* prototype */
int WINDLL_GTKMM dll_exported_function(void);

An exported variable:

/* header */
extern WINDLL_GTKMM int dll_exported_variable;


Then you only need to set GTKMM_DLL as default define if you compile the gtkmm.dll. If you use the dll don't define anything. For a static library just define WINDLL_GTKMM to nothing.


Regards,
Frank



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]