Repository navigation
Fix static library usage on windows by handling autogenerated import libraries on CMake install/link - #61
Merged
Conversation
Owner
|
Hi there, Thank you for the contribution! Given how complex the Prism build systEm is I tend to be very careful with PRs that modify the build system in ways like this, since I have tried hard to avoid exportation of internal CMake targets. However, this may be one of those instances where this is inevitable. I will allow CI to finish and do another review pass and, should this be good, it will be merged and in 0.16.7. |
Contributor
Author
|
Hi, Just making sure that this failing check involving an artifact upload not working is Github's fault, not mine? Was just attempting to be proactive encase I needed to fix anything. |
Owner
|
@samtupy This appears to possibly be GHA being GHA and it's usual unreliable self? Am re-running to verify. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When Prism is built for windows, several import libraries (boy_pc_reader.lib, pc_talker.lib, zdsr.lib etc) - things from the defs folder are generated. When building as a DLL, this does not present any issue as everything is linked into a final package.
When building Prism as a static library, however, CMake does not deliver these import libraries as linkable artifacts to the user. They won't get installed (vcpkg_cmake_install), and they won't be linked in the Prism CMake target. This causes undefined symbol errors upon linking a final end product using the Prism static library when code in prism.lib tries to access, for example, the Speak() function from zdsr. For instance
prism.lib(zdsr.cpp.obj) : error LNK2001: unresolved external symbol __imp_SpeakThis PR causes the build to keep track of these generated import libraries and, only if the build is static, to both include them in the install list and to link them in the generated CMake target. When the diff this PR incapsolates is applied as a vcpkg overlay port patch, I am successfully able to include ethindp-prism as a vcpkg dep, build with a static triplet, and link a final output product. When building as shared, the generated import libraries are left entirely alone as before.
NOTE! I am beyond lousy with CMake syntax, so once I discovered the source of my prism linkage error, though with specific instruction and testing after the fact, I allowed CLAUDE to do the gruntwork here. Everything seems to work fine and the diff looks perfectly logical to me, but might be worth a careful extra look just encase. Not knowing the CMake language, I cannot improve this further - I just know it works perfectly as a VCPKG patch and thought to share the fix encase it's helpful either directly or otherwise.
Thanks for the great library!