diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2019-05-13 13:45:32 +0530 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-05-13 23:24:18 +0300 |
commit | b849f6f935787055834ed3745faf7203c22c982b (patch) | |
tree | 568c16b54c1df998435a44beb0ca3006a0ce6491 /docs | |
parent | cacc585b44d11ed680e6d3ad6c716b38bd8818a1 (diff) | |
download | meson-b849f6f935787055834ed3745faf7203c22c982b.zip meson-b849f6f935787055834ed3745faf7203c22c982b.tar.gz meson-b849f6f935787055834ed3745faf7203c22c982b.tar.bz2 |
FAQ: Add an entry about the library naming scheme with MSVC [skip ci]
This is very frequently asked.
Diffstat (limited to 'docs')
-rw-r--r-- | docs/markdown/FAQ.md | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/docs/markdown/FAQ.md b/docs/markdown/FAQ.md index 0208c1a..139e192 100644 --- a/docs/markdown/FAQ.md +++ b/docs/markdown/FAQ.md @@ -365,3 +365,37 @@ compiler. - If the compiler is freely available, consider adding it to the CI system. + +## Why does building my project with MSVC output static libraries called `libfoo.a`? + +The naming convention for static libraries on Windows is usually `foo.lib`. +Unfortunately, import libraries are also called `foo.lib`. + +This causes filename collisions with the default library type where we build +both shared and static libraries, and also causes collisions during +installation since all libraries are installed to the same directory by default. + +To resolve this, we decided to default to creating static libraries of the form +`libfoo.a` when building with MSVC. This has the following advantages: + +1. Filename collisions are completely avoided. +1. The format for MSVC static libraries is `ar`, which is the same as the GNU + static library format, so using this extension is semantically correct. +1. The static library filename format is now the same on all platforms and with + all toolchains. +1. Both Clang and GNU compilers can search for `libfoo.a` when specifying + a library as `-lfoo`. This does not work for alternative naming schemes for + static libraries such as `libfoo.lib`. +1. Since `-lfoo` works out of the box, pkgconfig files will work correctly for + projects built with both MSVC, GCC, and Clang on Windows. +1. MSVC does not have arguments to search for library filenames, and [it does + not care what the extension is](https://docs.microsoft.com/en-us/cpp/build/reference/link-input-files?view=vs-2019), + so specifying `libfoo.a` instead of `foo.lib` does not change the workflow, + and is an improvement since it's less ambiguous. + +If, for some reason, you really need your project to output static libraries of +the form `foo.lib` when building with MSVC, you can set the +[`name_prefix:`](https://mesonbuild.com/Reference-manual.html#library) +kwarg to `''` and the [`name_suffix:`](https://mesonbuild.com/Reference-manual.html#library) +kwarg to `'lib'`. To get the default behaviour for each, you can either not +specify the kwarg, or pass `[]` (an empty array) to it. |