I'm working in a C++ workspace in VS2017, having two projects in the workspace: a utility project and a main project that uses the utility project.
After I added a new class (".h" and ".cpp" files) to the utility project, I noticed that although I make changes in the code, the ".lib" file is not rewritten when I build it, unless I change a method whose declaration includes __declspec(dllexport)
. It appears that I have to add this declaration, since otherwise, a derived issue is that of course the main project has linkage errors.
Is there a more elegant way to do it rather than adding __declspec(dllexport)
before the declaration of every public method, like in the code below?
public:
__declspec(dllexport) MyProperty(const std::string &csvLine);
__declspec(dllexport) bool getIsActive();
__declspec(dllexport) std::string getFormatting();
__declspec(dllexport) PropertyType getType();