Skip to content

Fix static library usage on windows by handling autogenerated import libraries on CMake install/link - #61

Merged
ethindp merged 1 commit into
ethindp:masterfrom
samtupy:static-winlibs
Jun 22, 2026
Merged

ethindp merged 1 commit into
ethindp:masterfrom
samtupy:static-winlibs

Conversation

@samtupy

@samtupy samtupy commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

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_Speak

This 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!

@ethindp

ethindp commented Jun 22, 2026

Copy link
Copy Markdown
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.

@samtupy

samtupy commented Jun 22, 2026

Copy link
Copy Markdown
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.

@ethindp

ethindp commented Jun 22, 2026

Copy link
Copy Markdown
Owner

@samtupy This appears to possibly be GHA being GHA and it's usual unreliable self? Am re-running to verify.

@ethindp
ethindp merged commit 8ae7388 into ethindp:master Jun 22, 2026
124 of 127 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants