How do I properly export shared library symbols (for linking from client code in Visual Studio) while making sure the code is cross-platform? Specifically is using .def the recommanded way or should I use platform-specific macro for __declspec(dllexport)? If macro should be used, can you give an example that is cross platform friendly?
I have some native C++ code for cross platform use, and used Cmake to generate .sln/.vcxproj file which creates .dll file for use in Windows. To link to this dll from a C++/CLI wrapper (also a dll) I need to have .lib, which requires exporting symbols. I learned I need to use either __declspec(dllexport) or .def file. My concern is I don't want to temper the shared code with MSVC stuff (we need to support Linux, iOS, Mac OSX, Android ...).