clinuxheader-filesarchlinuxc-header

Header file is in the wrong location


I wanted to include xf86drmMode.h in my c code, but when I did it says there was an error in the header file as it couldn't find drm.h. It's because there is no drm.h on my system, there's only libdrm/drm.h. What am I meant to do? Edit the header? I mean I guess I could but would that cause issues in my system?

I tried using sudo pacman -Syu linux-headers libdrm but nothing changed. Theres no straight up drm package either to install.

> ls /usr/include | grep "drm"
libdrm                                                                           
xf86drm.h
xf86drmMode.h
> ls /usr/include/libdrm                                                                                                 
amdgpu_drm.h  drm_mode.h   intel_bufmgr.h  msm_drm.h      r128_drm.h       radeon_bo_int.h  radeon_drm.h      tegra_drm.h    vmwgfx_drm.h
amdgpu.h      drm_sarea.h  intel_debug.h   nouveau        r600_pci_ids.h   radeon_cs_gem.h  radeon_surface.h  vc4_drm.h
drm_fourcc.h  i915_drm.h   mach64_drm.h    nouveau_drm.h  radeon_bo_gem.h  radeon_cs.h      savage_drm.h      via_drm.h
drm.h         intel_aub.h  mga_drm.h       qxl_drm.h      radeon_bo.h      radeon_cs_int.h  sis_drm.h         virtgpu_drm.h

Solution

  • What am I meant to do?

    Add /usr/include/libdrm to compiler include search path.

    Typically a build system is used. Looking at the output of pacman -Ql libdrm I see pkgconfig. Use:

    gcc $(pkgconf --cflags --libs libdrm)
    

    to compile programs. If you check pkgconf --cflags --libs libdrm you'll see it adds -I/usr/include/libdrm to compile include search paths.

    Edit the header?

    No.

    would that cause issues in my system?

    Yes.