-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Support static linking with /MT /MTd #36
Comments
DLLs are the hardest, so we've focused on them first, but static linking is definitely a needed feature! Our current plan (open for discussion) is to have /MT be configured in the triplets files. So, you would add a single line to In Visual Studio, this triplet would automatically get picked whenever |
If we're discussing static linking, it might be worthwhile asking how to handle LTCG (primarily for the purposes of PGO), as not all libraries can be compiled as static libraries. (there are probably a few out there that don't play nice with LTCG, but those should be significantly rarer) Are there any plans to also support individual libraries as statically-linked but built against the dynamic runtime? |
I have created a new branch: staticlibs. In this branch we introduce an initial approach to supporting static libs. The triplet definitions in To install zlib dlls or static libs you need the following commands, respectively:
We welcome feedback on the approach we have taken. In particular, one of the points that was raised is the name of the triplets. Some alternatives are:
|
Is this issue resolved via #97 and therefore can be closed or is there still something missing needing to be addressed @aardappel |
@adam4813 : thanks, this is very helpful. One issue that worries me is that now each package needs to explicitly support static linking in its portfile, and if portfile authors are generally omitting this, it will be some pain for those using static linking getting that fixed. Since most open source libraries have no particular requirements on what their code gets compiled into, a default solution that automagically is able to link statically would have been even better. But this is already entirely workable, so feel free to close the issue. |
To fill in a few more details about the support we've added with #97: these settings are controlled by the variables
@Orvid Yes, this is supported! We don't currently ship with a triplet that has the appropriate settings, but you can create your own triplet or modify the existing ones. Finally, due to unfortunate interactions with the core of C++'s MSBuild, it is exceedingly difficult to reliably switch triplets based on the project's CRT linkage so we have removed that particular feature.
[1] https://github.com/Microsoft/vcpkg/blob/master/triplets/x86-windows.cmake#L2 |
Thanks, that's even better :) |
* Inherit gitattributes from the vcpkg repository when archiving tree Ensures that file endings are consistent between the ports and the versioned port under `versioning`. Fixes microsoft#16615 (comment). Before this fix, a patch with LF endings could end up with CRLF endings on Windows causing corrupt patch issues. * Explicitly set core.autocrlf as false Co-authored-by: Robert Schumacher <roschuma@microsoft.com> * fix formatting * -c has to be before archive command Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
The following PRs are included: * hopefully fix crash in constraints (microsoft#60) * [vcpkg] allow --version to check the version (microsoft#50) * Remove baseline warning (microsoft#27) * [git] always pass autocrlf=false (microsoft#58) * ignore QtCreator CMake project files (microsoft#54) * ignore .DS_store files (microsoft#53) * [vcpkg] x-add-version now also checks if the manifest file is properly formatted (microsoft#43) * hopefully fix ci issue microsoft#16773 (microsoft#34) * Add docs to set VCPKG_ROOT to run tests (microsoft#45) * [vcpkg] x-add-version improve speed by calling get_builtin_baseline only once (microsoft#44) * add clang-format version to format-cxxcode (microsoft#41) * [vcpkg] Introduce experimental workaround X_VCPKG_NUGET_ID_PREFIX (microsoft#40) * [supports] Add `native` identifier expression and x-check-support command (microsoft#29) * [metrics] Split reporting of installs into name:triplet (microsoft#39) * [vcpkg] Improve error when accessing missing feature (microsoft#38) * [vcpkg] Allow shallow git registries (microsoft#37) * Disable git autocrlf when archiving tree (microsoft#36) * Use only named packages from extra registries (microsoft#35) * [registries] add metrics (microsoft#30) * Add vcpkg policy cmake helper port support (microsoft#17) * [osx] add support for rosetta (microsoft#23) * don't build tls12-download unless it's needed (microsoft#33) * Add new telemetry points for versioning (microsoft#21) * add cmake_minimum_required to vcpkg_tags (microsoft#25) * [x-add-versions] Perform atomic replacement of versioning files (microsoft#28) * [tools] support gsutil (microsoft#19) * add CUDA 11.1 and 11.2 to KEEP_ENV_VARS defaults (microsoft#26) * Add finite timeout on CURL metrics endpoint. (microsoft#22) * fix UB in make_error_code(utf8_errc) (microsoft#18)
[qtkeychain] remove from overlay and adjust port name
Maybe it is already possible, but the docs so far appear to imply code gets compiled into DLLs.
Please also support compiling all code into a .lib with /MT /MTd runtime libraries for those of use who prefer their executables to be self-contained (or document how it is done).
The text was updated successfully, but these errors were encountered: