-
Notifications
You must be signed in to change notification settings - Fork 378
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
Can't link with Jack when using MSVC to build application #792
Comments
I've seen old issues/PR about using dllimport/dllexport, is there any reason to not use that (maybe technical difficulties to get it right / missing time ?) |
Not really, can you point me to those? |
It was #287. Can you tell me how the library is built, how I can detect if the library is being built or used by external code ? Line 146 in 1ab3445
A define will be needed for clientlib and serverlib to tell the code to use dllexport, and when not defined (that is, when headers are being used by an application) use dllimport instead. |
That is a ticket, not a PR ;) You can check github actions for how it is built, since we have automated builds there.
Yes
Yes, but there is more than 1 library. There is libjack, libjackserver and libjacknet, not sure if more now.. There is already a macro for the exported symbols. |
Actually there is a separate macro for the exported symbols inside the jack server/client code, besides that one. |
Yes it seems SERVER_EXPORT is what is needed for jack APIs, with already made macro to differentiate uses (dllimport) vs build (dllexport) |
Since you are able to reproduce the issue, feel free to try some changes and then the generated builds. |
Well in fact SERVER_EXPORT is not available from application, as it is defined in private headers. I don't think JACK_LIB_EXPORT should be reused because it is used to export symbols for in-process "applications" (which are really DLLs in fact) ? I can just move all SERVER_EXPORT related code to common/jack/systemdeps.h instead (it is not used currently anyway). |
Ah no SERVER_EXPORT is used, I though the search was just "SERVER_EXPORT" but it was "#define SERVER_EXPORT" |
Current API is exported using LIB_EXPORT, this is the one I will use (and rename to move it to headers) |
Is it supported to build statically the clientlib and serverlib ? |
no, and it doesnt make any sense. if you do that, no external client would be able to connect. |
I've tried to do something but I fear I will just get a bunch a failure which would requires major code change to fix (I'm not sure to understand all impacts of these change to be honest across the different libraries ^^) |
You cant include common/jack headers in main jack2 code, I cant tell you why because I didnt do it, but the header files are defined separately. basically the header stuff is defined twice. |
I've tried to only modify common/jack headers as they would only be used by applications that link to clientlib, but it seems to be more complex than that, I get errors about symbols being both exported and imported or just missing:
https://github.com/amurzeau/jack2/runs/3386254201?check_suite_focus=true It seems there are files compiled multiple time for different targets, but I can't wrap my head around that and see what's being used for which target
I guess the build could work if a whole different set of headers would be installed as public headers instead of common/jack/
I think this would work but it will be probably a pain to maintain .... |
Just confirmed, I've copied the modified common/jack headers from my commit to an existing installation of jack, and linking qjackctl works with MSVC now |
When building jack, symbols are declared using dllexport. When headers are used by an application, symbols will be declared using dllimport. Fixes: jackaudio#792
When building jack, symbols are declared using dllexport. When headers are used by an application, symbols will be declared using dllimport. Fixes: jackaudio#792
When building jack, symbols are declared using dllexport. When headers are used by an application, symbols will be declared using dllimport. Fixes: jackaudio#792
jackaudio does not play well with msvc, since almost all of the symbols are not exported see: jackaudio/jack2#792 jackaudio/jack2#793
Describe the bug
When building an application (like qjackctl) using MSVC, there are link errors because of missing symbols in libjack64.lib:
Exported data (like
JACK_METADATA_PRETTY_NAME
) must be imported usingdllimport
and cannot be imported with just a .lib file.See here: https://developercommunity.visualstudio.com/t/unresolved-external-symbol-when-linking-with-def-f/1215422
Environment
Steps To Reproduce
See appveyor script here:
https://github.com/amurzeau/qjackctl/blob/a49d6921a7c7621a8641b453d918c054829d9dc4/appveyor.yml
and resulting build here:
https://ci.appveyor.com/project/amurzeau/qjackctl/builds/40460558/job/nmok18x7js587fye
Expected vs. actual behavior
If linking Jack using the MSVC compiler should be supported, it should be possible to link with it without errors.
The text was updated successfully, but these errors were encountered: