[Solved] Imlib2-config and Imlib2 library

Hi! I’m trying to build a simple program.

/* main program */
int main(int argc, char **argv)
{
  /* an image handle */
  Imlib_Image image;
  
  /* if we provided < 2 arguments after the command - exit */
  if (argc != 3) exit(1);
  /* load the image */
  image = imlib_load_image(argv[1]);
  /* if the load was successful */
  if (image)
    {
      char *tmp;
      /* set the image we loaded as the current context image to work on */
      imlib_context_set_image(image);
      /* set the image format to be the format of the extension of our last */
      /* argument - i.e. .png = png, .tif = tiff etc. */
      tmp = strrchr(argv[2], '.');
      if(tmp)
         imlib_image_set_format(tmp + 1);
      /* save the image */
      imlib_save_image(argv[2]);
    }
}

This program use Imlib2 library. In the manual the way for compile is cc imlib2_convert.c -o imlib2_convert `imlib2-config --cflags` `imlib2-config --libs` . I have tried to install imlib2 with nix-shell -p imlib2. But I can’t find the imlib2-config utility.
My question is: How can I compile this program in NixOS?
Thanks!

I have added headers for libs:

#include <Imlib2.h> // For Imlib2
#include <stdlib.h> // For exit
#include <string.h> // For strrchr

/* main program */
int main (int argc, char **argv) {
  /* an image handle */
  Imlib_Image image;

  /* if we provided < 2 arguments after the command - exit */
  if (argc != 3) exit(1);

  /* load the image */
  image = imlib_load_image(argv[1]);

  /* if the load was successful */
  if (image) {
    char *tmp;
    /* set the image we loaded as the current context image to work on */
    imlib_context_set_image(image);
    /* set the image format to be the format of the extension of our last */
    /* argument - i.e. .png = png, .tif = tiff etc. */
    tmp = strrchr(argv[2], '.');
    if (tmp)
      imlib_image_set_format(tmp + 1);
    /* save the image */
    imlib_save_image(argv[2]);
  }
}

For compile I have done following:

charlzk@nixos-test ~/P/Imlib2> nix-shell -p xorg.libX11 imlib2 

[nix-shell:~/Projects/Imlib2]$ gcc imlib2_convert.c -o imlib2_convert -lImlib2

That’s it!

imlib2-config tool has been removed a while ago, you should use pkg-config instead:

cc imlib2_convert.c -o imlib2_convert $(pkg-config --cflags --libs imlib2)

Using just -lImlib2 only works because the stdenv in Nixpkgs adds -L and -I flags implicitly but it is not really portable.

Thank you for advice!