-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding declspec export attribute to header functions #220
Conversation
or build the library with gcc (rather than msvc) which has an option to export all the symbols. |
sidenote: i'm not at all opposed against adding a in general i'm a big fan of using hidden symbols by default for libraries (only symbols explicitly exported via so yes, but please do not stop at MSVC. |
In vcpkg the default compiler triplet for windows uses msvc so getting it to compile with msvc would be preferred |
What the library currently does is generate a mysofa_export.h header from a config as you suggested. The problem is that this header is not installed so it can't be safely just included in mysofa.h. Which is only part of the problem, each function still needs to be marked up with MYSOFA_EXPORT define so that when a downstream project includes the header it knows that the functions have the |
so the solution is to install the header, no? this of course would complicate the includes from a simple single |
I tried the vcpkg x64-mingw-dynamic and x64-mingw-static triplets and I can't find any issues with them. So it seems like this change is compatible with non-msvc compilers on Windows |
This is why I didn't do that. I wasn't sure what the preference was so I did it the way that I thought would be the least invasive |
my comment was not about introducing incompatibilities, but about doing it properly rather than halfway: other systems (e.g. gcc on Linux) can benefit from the change as well. also note the inconsistent behaviour mentioned in #220 (review) |
It sounds like a solution to this is to define |
So TIL about cmake's Looks like the way cmake expects you to use this is, yeah, to make sure the generated header is installed so downstream projects can include it. |
I updated my port to use this and then made sure a downstream project could consume it and it looks to work |
@ColdenCullen said
Yes, that's what I've been trying to say. |
Any feedback for the latest version of this? Seems like I was wrong and the right answer was to include and install the header that Cmake generated |
Hate to necro an old PR but wanted to swing back to this. What's the current feedback for this change as it currently exists? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks reasonable for me.
Hi there! I'm trying to get libmysofa added to vcpkg so it will be available to more users. Also steam-audio uses libmysofa and I'd like to use steam-audio from vcpkg 😄
See: microsoft/vcpkg#38368
For my vcpkg port I ran into an interesting problem that this patch addresses. Without this any downstream project that depends on libmysofa will fail to properly link to the library on windows. Not sure if this is the way you'd like to fix this. We could also do a .def file for the linker to mark these functions as part of the export .lib.