Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2005-02-23 20:41:15


Gennadiy Rozental wrote:
> Hi,
>
> I am trying to finally implement DLL version of Boost.Test
> components. Here is several issues/questions I have:
>
> 1. main() function
>
> AFAIK there is no way to put a main function in DLL on windows. What
> should we do instead? I reworked the framework specifically for the
> purpose of making this kind of separation easier. But I still would
> like to hear what people think in this regard.

The equivalent to an entry point routine in a DLL is most often called
DllMain or DllEntryPoint with some compilers. There are many things one can
not do in the Dll entry point and it is used just as a way of initializing
the Dll.

If you need some function that actually serves to call other functionality
in a Dll as if you had a main() routine in an exe, pick out whatever name
you think appropriate, add it as a function in your Dll and export it so
that it can be called from outside the Dll.

>
> 2. main() function again
>
> On unix(s) there is a possibility to put main info dlls (If I am wrong
> please correct me). Should we use different semantic for Windows and
> Unix(s) or use the one I implement for windows?
>
> 3. init_unit_test_suite
>
> I need to call external function from inside of DLLs. How it should be
> declared? Cause I am getting unresolved symbols error

Most Windows compilers support __declspec(dllexport) or
__declspec(dllimport) in front of a function or class name and it is used
like:

#if defined(BUILD_MY_DLL)
#define MY_DLL_IMPORT_EXPORT_MACRO __declspec(dllexport)
#elif defined(USE_MY_DLL)
#define MY_DLL_IMPORT_EXPORT_MACRO __declspec(dllimport)
#else
#define MY_DLL_IMPORT_EXPORT_MACRO __declspec(dllimport)
#endif

and then for some function or class you want to export/import you write:

MY_DLL_IMPORT_EXPORT_MACRO void SomeFunction();

or

MY_DLL_IMPORT_EXPORT_MACRO class SomeClass { // etc. };

Often USE_MY_DLL can be defined internally depending on whether you can
figure out whether or not the module is being used as a DLL or a static
library, else the user can be required to define it or not.

>
> 4. runtime-link
>
> In my Jamfile in default build section of build rule there is
> <runtime-link>static/dynamic. Should I keep this? Should I use static
> for
> lib rule and dynamic for dll rule? Nothing for lib dynamic for dll?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk