Skip to content

Commit d2714eb

Browse files
authored
Merge pull request #2655 from mgorny/kb-win-naming-conventions
KB: add a section on Windows install paths and naming conventions
2 parents 3d1dfbd + 620a998 commit d2714eb

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

docs/maintainer/knowledge_base.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,45 @@ Some packages do not provide build systems with first-hand support for Windows,
349349
You can use the [autotools_clang_conda](https://github.com/conda-forge/autotools_clang_conda-feedstock?tab=readme-ov-file#about-autotools_clang_conda-feedstock) to provide a build environment with a set of MSYS2 packages and a Clang toolchain configured to build packages compatible with MSVC.
350350
The feedstock's description provides example instructions.
351351

352+
<a id="install-paths-and-naming-conventions"></a>
353+
354+
### Install paths and naming conventions
355+
356+
Unix-style packages in conda-forge are installed into a special `Library` directory tree under the build prefix.
357+
For the convenience of writing build scripts, both conda-build and rattler-build define the following variables:
358+
359+
| Variable | Value | Use |
360+
| ---------------- | -------------------------- | ------------------------------------------------------- |
361+
| `LIBRARY_PREFIX` | `%PREFIX%\Library` | Prefix for installing packages |
362+
| `LIBRARY_BIN` | `%PREFIX%\Library\bin` | Executables and DLL libraries (`.exe` and `.dll` files) |
363+
| `LIBRARY_INC` | `%PREFIX%\Library\include` | Header files |
364+
| `LIBRARY_LIB` | `%PREFIX%\Library\lib` | Import and static libraries (`.lib` files) |
365+
| `SCRIPTS` | `%PREFIX%\Scripts` | Python scripts |
366+
367+
On Windows, it is not possible to link directly to dynamic libraries (`.dll` files); the linker needs to use so-called import libraries instead.
368+
Import libraries have the same format and generally use the same suffix (`.lib`) as static libraries.
369+
Therefore, whenever both dynamic and static libraries are installed, the import library and the static library must use different names.
370+
There are two main naming conventions for installing libraries on Windows: the MSVC convention and the GCC/MinGW convention.
371+
372+
The MSVC convention uses the following names:
373+
374+
- dynamic library: `{name}.dll` (e.g. `zlib.dll`)
375+
- import library: `{name}.lib` (e.g. `zlib.lib`)
376+
- static library: no standard convention, often `lib{name}.lib` or `{name}-static.lib` (e.g. `zlibstatic.lib`)
377+
378+
Usually, `{name}` does not include a `lib` prefix.
379+
Following this convention ensures that `-l{name}` works for dynamic linking, same as on Unix.
380+
However, some packages do use `lib` prefix for historical reasons, e.g. `libprotobuf.dll` + `libprotobuf.lib`.
381+
382+
The GCC/MinGW convention uses the following names:
383+
384+
- dynamic library: `lib{name}.dll`
385+
- import library: `lib{name}.dll.a`
386+
- static library: `lib{name}.a`
387+
388+
There is no standard convention for providing SONAME-style versioning for libraries.
389+
Some packages do not provide versioning at all, others embed the version into the `.dll` name (but not the import library name, to preserve `-l{name}` behavior).
390+
352391
<a id="special-dependencies-and-packages"></a>
353392

354393
## Special Dependencies and Packages

0 commit comments

Comments
 (0)