C: Difference between revisions

imported>Nathanruiz
mNo edit summary
imported>Tobias.bora
Add explaination how to use pkg-config with gtk-3.0
Line 55: Line 55:
In <code>$NIX_CFLAGS_COMPILE</code> we see that the include search path is extended by appending new directories
In <code>$NIX_CFLAGS_COMPILE</code> we see that the include search path is extended by appending new directories
using the <code>-isystem</code> flag.
using the <code>-isystem</code> flag.
However, while the <code>$out/include</code> folder will be included by default, it may sometimes not be enough when the lib puts the header in a subfolder (for instance, gtk2 and gtk3 uses subdirectories like <code>$out/include/gtk-2.0</code> instead to avoid conflict between versions). To deal with this kind of libraries, one can use `pkg-config`: the idea is simply to add `pkg-config` in the <code>nativeBuildInputs</code>, and then to start the <code>buildPhase</code> with:
<syntaxHighlight  lang=nix>
buildPhase = ''
  NIX_CFLAGS_COMPILE="$(pkg-config --cflags gtk+-3.0) $NIX_CFLAGS_COMPILE"
  # put the usual make/gcc code here
'';
</syntaxHighlight>


For <code>$NIX_LDFLAGS</code> see that the library link path is extended  
For <code>$NIX_LDFLAGS</code> see that the library link path is extended