|
Boost : |
From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-02-23 21:30:15
Edward Diener wrote:
> Gennadiy Rozental wrote:
>> 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();
I think Gennadiy wants the dll code to call a user-defined function, and the
problem is that if you declare the function and then leave it undefined the
linker complains, even though this works fine with static linking, since the
user supplies the definition and the linker sees everything at once.
Jonathan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk