Last modified 10 years ago Last modified on 07/03/08 18:00:12

How to develop simple dcap clients tools using libdcap with C

  1. Get yourself a copy of the dcap source code by either checking out complete dCache or just the submodule dcap.

In case you checked out, build the library simply by typing make.

  1. Important files
  • (the binary of the dcap client lib, either built by you through the previous make or shipped with the dcache-server-rpm under /opt/d-cache/dcap/lib)
  • dcap.h (main interface to dcap, either part of the dcap source or shipped with the dcache-server-rpm under /opt/d-cache/dcap/include/)
  • dcap_test.c (good example, start here to look how to use libdcap)
  1. How to compile you app, linked against libdcap
gcc -D_GNU_SOURCE -I/opt/d-cache/dcap/include/ -L/opt/d-cache/dcap/lib -ldcap -o /tmp/dc_exists /tmp/dc_exists.c 
  1. A simple example how to check whether a file exists (dcap stat)
#include <dcap.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])

   if( argc != 2 ) {
      printf("usage: %s <filename>
", argv[0]);


   return dc_access(argv[1], F_OK);