Converting an application to use dlls. class 'std::map<_Kty,_Ty>' needs to have dll-interface to be used by clients of class
This seems to be a common error, but most people online choose to just ignore the warning and move on. I do not wish to ignore the warning.
Basically, when using __declspec(dllexport) to convert a p开发者_如何学Pythonroject to use dlls, the compiler has trouble dealing with templates and stl objects. An explanation of the problem, and suggested solution are listed here. I have implemented the giant #define statement suggested for maps, to no avail.
How do you make this work!? My code is absolutely littered with things like wchar_ts and std::maps, so hopefully a solution that doesn't involve writing something remotely complex for each class!
Read this similar thread for a good discussion of the topic. I would suggest either of the following:
- Use a static library
- Hide all
template
-related types and interfaces behind non-template
compiler firewall orpimpl
.
After fighting with the linker changes from Visual C++ 6.0, to 2003, and then to 2005, I will never __declspec(dllexport)
anything that has a template
, bool
, wchar_t
, or time_t
in the signature again. Actually, we just out-right stopped using DLLs altogether. Life is so much simpler now ;)
精彩评论