Fix: #197 windows shared libraries build support #198
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#197 reports that building on windows with
-DBUILD_SHARED_LIBS
fails.The direct failure is to find zlib.lib which is used by few targets within pdfhummus project (pdfwriter, libtiff, libpng).
The failure is because no symbols are exported when compiling zlib and therfore no .lib file is created, only a dll.
This problem is not specific to the bundled zlib target, but is also true to all other targets, including PDFWriter. As a result building with
BUILD_SHARED_LIBS
is kinda pointless - you'll get a dll out but can't do anything with it.This PR tends to that by adding symbol exporting to all targets. as a result lib files are created and linking completes. also symbols are exported for PDFWriter.
Most bundled lib had existing support for symbol exporting and just adding a compile definition solved the problem. I had to upgrade freetype for this...but it's not all bad cause while doing so i figured there's quite a bit of included code i don't need for freetype and got rid of quite a bit of content. Only libtiff and PDFWriter didn't have export symbols setup for them. For those two i added WINDOWS_EXPORT_ALL_SYMBOLS so that they'll automatically export all symbols. effective if not very sensitive.
One last note. when building shared libs the Ctest bit will fail because the executable created cant find the shared dlls. i solved this by copying the other 6 dlls to its folder and then it passed all tests. didn't bother with automating something here because i'm not sure it's super interesting to make it work this way.
anyways, problem solved and building succeeds.