holocronweaver wrote:
...allows me to easily check that library updates cause no problems in my projects without recompiling them, and allows me to update all my projects simultaneously with a single file change. In addition, it allows my users to swap out or patch libraries to their liking. Even if I were to fall off the face of the Earth and my users stranded without source code access, they could at least fix bugs arising from the libraries.
This sounds good in theory but doesn't work in practice. You see, PolyVox is almost entirely header files, and these will be compiled directly into your application regardless of whether you are linking statically or dynamically. Have a look at the number of header files (.inl files are also headers) here:
https://bitbucket.org/volumesoffun/polyvox/src/95f0aa22c12dde4b6e145f6b057a84cee006a5b0/library/PolyVoxCore/include/PolyVoxCore?at=masterversus the number of source files here:
https://bitbucket.org/volumesoffun/polyvox/src/95f0aa22c12dde4b6e145f6b057a84cee006a5b0/library/PolyVoxCore/source?at=masterIf you open a few source files you'll see they mostly have very little code. The only significant stuff that gets compiled into a library is the Region class and static data such as the Marching Cubes tables.
All significant code such as volumes and surface extractors are simply in header file which are included by your application and compiled into it. This is done because PolyVox is highly templatised and including definitions in header files is the only practical way to do templates (C++'s
Exported Templates feature was never widely supported and is now removed from the standard).
holocronweaver wrote:
I can certainly understand defaulting to static builds on Windows, but disallowing dynamic builds all together seems a bit much. I realize that dynamic linking in Windows can be awry, but I still feel the above mentioned benefits outweigh the costs.
Except it seems those benefits don't really exist (as described above). Updating the .dll will just trick you into thinking you are updating PolyVox. It doesn't update any significant part of PolyVox but may mean you have a mismatch between the code that has been compiled into your executable and the data in your .dll.
holocronweaver wrote:
Besides, most people wanting to do the dynamic linking are just going to modify the CMake files as I have, so why make them go through the hassle? If you prefer not to support and test dynamic linking, you could include a warning message in the CMake output stating so.
I was going to agree with you, but then I started writing the arguments above and convinced myself otherwise
It might be bad if users do this because they convince themselves they are getting benefits which they are not really. We could actually prevent it by removing the '__declspec(dllexport)' which Visual C++ requires for building a .dll (though I'm not saying we should... maybe a warning is enough).
holocronweaver wrote:
The only part I do not understand is how dynamic linking effects SWIG (as mentioned in the second link). Could you elaborate a bit? If it does cause problems, this too could be mentioned in a CMake warning. I am guessing this is a Windows-specific issue since I do not recall encountering it on Linux.
I forget the exact details, but there were problems with SWIG and the '__declspec(dllexport)' defined by POLYVOX_API. So each class now has to start with some logic like this:
Code:
#ifdef SWIG
class Region
#else
class POLYVOX_API Region
#endif
{
public:
Not a huge problem as we've solved it already, but still a bit ugly.