-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
[qt5] Do not link all .lib files #1792
[qt5] Do not link all .lib files #1792
Conversation
This commit moves a few .lib files to subfolders to prevent them from automatically getting linked: Qt5Bootstrap (dbg): This lib is linked against a release version of the CRT and is only meant for release builds. For debug builds, this lib should not be linked at all. qtmain (rel), qtmaind (dbg), Qt5AxServer (rel), Qt5AxServerd (dbg): These libs are mutually exclusive. The user either links against qtmain(d) for desktop applications or against Qt5AxServer(d) for ActiveX servers. See microsoft#1442 for more information.
@ShinNoNoir, |
This is the right solution, thank you for making the PR. Does this still work with CMake? Can |
@ras0219-msft I don't think this is the correct change as it breaks existing CMake functionality. For example with CMake > 2.8.11 simply adding |
@szechyjs Do you have any suggestions how to fix it in a way such that things also still work in a plain vanilla Visual Studio project? |
Hmm, I notice that
If these would be patched to reflect the Also, something similar would need to be done for |
I also see that |
I guess ultimately I don't understand the all .lib files are automatic dependencies. In the years that I've been using Qt, the |
I think I've found what you mean by all libs are automatic dependencies, from <Link>
<AdditionalDependencies Condition="$(VcpkgConfiguration.StartsWith('Debug')) and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)debug\lib\*.lib</AdditionalDependencies>
<AdditionalDependencies Condition="$(VcpkgConfiguration.StartsWith('Release')) and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)lib\*.lib</AdditionalDependencies>
<AdditionalLibraryDirectories Condition="$(VcpkgConfiguration.StartsWith('Release'))">%(AdditionalLibraryDirectories);$(VcpkgRoot)lib;$(VcpkgRoot)lib\manual-link</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories Condition="$(VcpkgConfiguration.StartsWith('Debug'))">%(AdditionalLibraryDirectories);$(VcpkgRoot)debug\lib;$(VcpkgRoot)debug\lib\manual-link</AdditionalLibraryDirectories>
</Link> In my opinion that is very bad form to automatically link every lib file found. However, I can understand why it was done, I'd just rather see an explicit list of libraries to link against in each project and have Regardless of how |
@szechyjs We definitely understand the desire to have a more "total" accounting for all your dependencies, which can be easily done by setting I'll look into the imported_location patch. |
I might have a possible fix which I'll soon commit and push to a test branch. Edit: PR is up. See #1847. |
This PR addresses issue #1442
Currently, all .lib files produced in the compilation process are marked as an automatic dependency. This results in two conflicts:
Qt5Bootstrap.lib
is a file that should only be used and linked against in release builds. This file is not meant to be linked against in debug builds.qtmain.lib
/qtmaind.lib
cannot be linked against at the same time asQt5AxServer.lib
/Qt5AxServerd.lib
. These two sets of lib files represent two different use cases (desktop applications vs. ActiveX servers).The first conflict is resolved by moving
Qt5Bootstrap.lib
fromdebug\lib
to a dummy subfolder. Note that simply deleting this file does not work at the moment since the warning generated byPostBuildLint
'scheck_matching_debug_and_release_binaries(...)
is actually considered to be an error.The second conflict is resolved by moving the .lib files to a
manual-link
subfolder. This does mean, however, that users of theqt5
package now have to explicitly specifyqtmain.lib
/qtmaind.lib
(orQt5AxServer.lib
/Qt5AxServerd.lib
) as a lib dependency.