I am creating a wrapper DLL for boost containers (map, vecrtor, set..). In my application, I want to export the C++ object from the DLL to the client. So I am left with two option for exporting:
(_declspec)dllexport and use in client.CreateMap).I am using the containers(map, vector..) extensively in the client.
Can any one please help me, which will be the best method for exporting?
Having C++ classes and STL containers at the DLL interface boundaries is very fragile and highly constraining for your clients: in fact, both the DLL and the client EXEs must be built with the same VC++ compiler version, and dynamically link to the same flavor of the CRT.
It's much safer and better practice to build DLLs exporting a pure C interface. Note that you can use C++ inside the DLL boundaries (this is basically what many Win32 C-interface APIs do).
As an alternative you may export pure C++ abstract classes (interfaces) from the DLL, which is basically what COM does.
You may find this CodeProject article interesting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With