# Runtime dependency on libintl.h

**URL:** https://discourse.nixos.org/t/runtime-dependency-on-libintl-h/29762
**Category:** Help
**Created:** [June 28, 2023, 7:11pm UTC](https://discourse.nixos.org/t/runtime-dependency-on-libintl-h/29762 "2023-06-28T19:11:02Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Guekka](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/g/3ab097/32.png) [@Guekka](https://discourse.nixos.org/u/Guekka)
#### Post date: [June 28, 2023, 7:11pm UTC](https://discourse.nixos.org/t/runtime-dependency-on-libintl-h/29762/1 "2023-06-28T19:11:02Z")

</div>

Hey. I’m trying to get ` vcpkg` to work under NixOS. It has required some workarounds, but it’s currently working fine.  
However, when compiling the `vcpkg` port `gettext-libintl`, I get the following error:

```auto
CMake Error at ports/gettext-libintl/portfile.cmake:4 (message):
  When targeting Linux, `libintl.h` is expected to come from the C Runtime
  Library (glibc). Please use "sudo apt-get install libc-dev" or the
  equivalent to install development files.

```

Adding `libintl` and `libiconv` to `buildInputs` does not work.

I tried to add `glibc.dev` to `buildInputs`, but this causes another error (see [this post](https://discourse.nixos.org/t/trouble-in-building-c-environment/1413))

I cannot patch the `#include`, as it’s a runtime dependency.

> **Full derivation**
>
> ```nix
> {
> autoconf,
> automake,
> bash,
> cacert,
> cmake,
> cmrc,
> coreutils,
> curl,
> fetchFromGitHub,
> fmt_9,
> gcc,
> git,
> glibc,
> gnumake,
> gperf,
> lib,
> libtool,
> libiconv,
> libintl,
> makeWrapper,
> meson,
> m4,
> ninja,
> perl,
> pkg-config,
> python3,
> runtimeShell,
> stdenv,
> zip,
> zstd,
> }
> : let
> runtimeDeps = [
> autoconf
> automake
> bash
> cacert
> coreutils
> curl
> cmake
> gcc
> git
> gnumake
> libiconv
> libintl
> meson
> ninja
> perl
> pkg-config
> python3
> zip
> zstd
> ];
> in
> stdenv.mkDerivation rec {
> pname = "vcpkg";
> version = "b18b17865cfb6bd24620a00f30691be6775abb96";
> 
> src = fetchFromGitHub {
> owner = "microsoft";
> repo = "vcpkg-tool";
> rev = "bedcba5172f5e4b91caac660ab7afe92c27a9895";
> hash = "sha256-XgYCa9aiG8lOraClfsFCk7U1qxvsfsIKbcBd2xBcNSw=";
> };
> 
> vcpkg_src = fetchFromGitHub {
> owner = "microsoft";
> repo = "vcpkg";
> rev = "5d2a0a9814db499f6ba2e847ca7ab5912badcdbf";
> hash = "sha256-UPThRUq8N2nmUoFMUgfLqu1JM3pjCz6mVdR11Iig4kE=";
> };
> 
> nativeBuildInputs = [
> cmake
> cmrc
> fmt_9
> makeWrapper
> ];
> 
> buildInputs = [
> libiconv
> libintl
> ];
> 
> cmakeFlags = [
> "-DVCPKG_DEPENDENCY_EXTERNAL_FMT=ON"
> "-DVCPKG_DEPENDENCY_CMAKERC=ON"
> ];
> 
> vcpkgScript = let
> out = placeholder "out";
> in ''
> #!${runtimeShell}
> vcpkg_hash=$(echo -n "${out}" | sha256sum | cut -f1 -d ' ')
> vcpkg_root_path="$HOME/.local/vcpkg/roots/$vcpkg_hash"
> if [[! -d $vcpkg_root_path]]; then
> mkdir -p $vcpkg_root_path
> ln -s ${out}/share/vcpkg/{docs,ports,scripts,triplets,versions,LICENSE.txt} $vcpkg_root_path/
> ln -s ${out}/bin/vcpkg $vcpkg_root_path/
> touch $vcpkg_root_path/.vcpkg-root # need write access
> fi
> 
> if [["$1" == "--root-for-nix-usage"]]; then
> echo "$vcpkg_root_path"
> exit 0
> fi
> 
> # Remove --vcpkg-root and --downloads-root from the command-line arguments
> args=()
> skip_next=false
> 
> for arg in "$@"; do
> if [["$skip_next" == true]]; then
> skip_next=false
> continue
> fi
> 
> if [["$arg" == "--vcpkg-root" || "$arg" == "--downloads-root"]]; then
> skip_next=true
> continue
> fi
> 
> args+=("$arg")
> done
> 
> echo "hello, i was called with $PATH"
> 
> export VCPKG_FORCE_SYSTEM_BINARIES=1
> exec ${out}/share/vcpkg/vcpkg \
> --vcpkg-root "$vcpkg_root_path" \
> --downloads-root "$vcpkg_root_path/downloads" \
> "''${args[@]}"
> '';
> 
> passAsFile = ["vcpkgScript"];
> 
> installPhase = ''
> cmake --build . --target=install --config=Release
> mkdir -p $out/share/vcpkg
> 
> cp --preserve=mode -r ${vcpkg_src}/{docs,ports,scripts,triplets,versions,LICENSE.txt} $out/share/vcpkg
> mv $out/bin/vcpkg $out/share/vcpkg/vcpkg
> cp $vcpkgScriptPath $out/bin/vcpkg
> chmod +x $out/bin/vcpkg
> touch $out/share/vcpkg/vcpkg.disable-metrics
> '';
> 
> postFixup = ''
> wrapProgram $out/share/vcpkg/vcpkg --set PATH ${lib.makeBinPath runtimeDeps}
> echo
> '';
> }
> 
> ```
> 
> And its dependency:
> 
> ```nix
> {
> lib,
> stdenv,
> fetchFromGitHub,
> cmake,
> }:
> stdenv.mkDerivation rec {
> pname = "cmrc";
> version = "2.0.1";
> 
> src = fetchFromGitHub {
> owner = "vector-of-bool";
> repo = "cmrc";
> rev = version;
> hash = "sha256-++16WAs2K9BKk8384yaSI/YD1CdtdyXVBIjGhqi4JIk=";
> };
> 
> cmakeFlags = [
> "-DBUILD_TESTS=OFF"
> ];
> 
> installPhase = ''
> dir=$out/share/cmakerc
> mkdir -p $dir
> mv CMakeRC.cmake $dir/cmakerc-config.cmake
> '';
> 
> meta = with lib; {
> description = "A Resource Compiler in a Single CMake Script";
> homepage = "https://github.com/vector-of-bool/cmrc";
> license = licenses.mit;
> maintainers = with maintainers; [];
> };
> }
> 
> ```

Is there something I’m missing?  
Thanks

---

<div class="post-metadata">

### Author: ![jtojnar](https://discourse.nixos.org/user_avatar/discourse.nixos.org/jtojnar/32/70_2.png) [@jtojnar](https://discourse.nixos.org/u/jtojnar)
#### Post date: [June 28, 2023, 8:02pm UTC](https://discourse.nixos.org/t/runtime-dependency-on-libintl-h/29762/2 "2023-06-28T20:02:50Z")

</div>

The project assumes [FHS](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard), which obviously will not work on Nix:

> <https://github.com/microsoft/vcpkg/blob/a293ce5897b839da7c22fbb2dc07943e3646f58a/ports/gettext-libintl/portfile.cmake#L3>

The solution is to patch that out.

---

<div class="post-metadata">

### Author: ![jtojnar](https://discourse.nixos.org/user_avatar/discourse.nixos.org/jtojnar/32/70_2.png) [@jtojnar](https://discourse.nixos.org/u/jtojnar)
#### Post date: [June 28, 2023, 8:05pm UTC](https://discourse.nixos.org/t/runtime-dependency-on-libintl-h/29762/3 "2023-06-28T20:05:06Z")

</div>

> [@Guekka](#):
>
> `cmake --build . --target=install`

Rather than call the install target manually, it is usually cleaner to let the generic builder invoke it for you and do extra installations in `postInstall`.

---

<div class="post-metadata">

### Author: ![Guekka](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/g/3ab097/32.png) [@Guekka](https://discourse.nixos.org/u/Guekka)
#### Post date: [June 28, 2023, 9:20pm UTC](https://discourse.nixos.org/t/runtime-dependency-on-libintl-h/29762/4 "2023-06-28T21:20:32Z")

</div>

Good catch. I thought this message came from the compiler, not from vcpkg itself. Thanks!

---

<div class="post-metadata">

### Author: ![Guekka](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/g/3ab097/32.png) [@Guekka](https://discourse.nixos.org/u/Guekka)
#### Post date: [June 28, 2023, 9:34pm UTC](https://discourse.nixos.org/t/runtime-dependency-on-libintl-h/29762/5 "2023-06-28T21:34:33Z")

</div>

Now I’m stuck building Qt, which refers to `/bin/pwd` in its [`configure` script](https://github.com/qt/qtbase/blob/d2368cde70062bbaa9db463d76cd135dccb55e23/configure)  
I guess I have to patch the vcpkg portfile, so that it patches Qt? _sigh_

But that’s another thing. Thanks for the help already
