Forcing symbol export with MSVC

后端 未结 5 547
我寻月下人不归
我寻月下人不归 2020-12-25 08:38

I have a application and several plugins in DLL files. The plugins use symbols from the application via a export library. The application links in several static libraries a

5条回答
  •  醉话见心
    2020-12-25 09:16

    You probably want to look at __declspec(export/import)

    #ifdef DLL_EXPORTING
    #define WHDLL __declspec(dllexport)
    #else
    #define WHDLL __declspec(dllimport)
    #endif
    

    When linking static module into a dll it will only bring in the code that is used. I've never imported stuff from a static lib to simply re export it.
    Perhaps you just need to mark it as exportable in the dll when compiling the static lib.

    But that reminds me of putting std containers into exported classes and using some trickery in msvc to export the 'instance' of the specialised container. the template code is similar to your static code (in my thinking)

    for instance without the template you get warnings the template code is not exported to support the class - this is MSVC specific from my understanding

    template class DLL_EXPORTING std::auto_ptr;
    class DLL_EXPORTING imageButton : public wxWindow
    {
        std::auto_ptr m_Cursor;
    };
    

提交回复
热议问题