sys/types.h: No such file or directory

38,375

Solution 1

I had a similar error with Linux Mint

fatal error: sys/types.h: No such file or directory

Fixed this problem with:

sudo apt install libc6-dev

Solution 2

I'd suggest looking to see if gcc is looking for header files in the directory where your file is located with the command:

`gcc -print-prog-name=cc1` -v      # for c

Solution 3

You can fix this problem with:

sudo apt-get install libc6-dev-i386

Solution 4

You can just add the types header file to your sources, download from here.

Share:
38,375
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    I am trying to compile module but get this error.

    fatal error: sys/types.h: No such file or directory
    compilation terminated.
    

    Here is my module file headers

    #include <linux/init.h>           // Macros used to mark up functions e.g. __init __exit
    #include <linux/module.h>         // Core header for loading LKMs into the kernel
    #include <linux/device.h>         // Header to support the kernel Driver Model
    #include <linux/kernel.h>         // Contains types, macros, functions for the kernel
    #include <linux/fs.h>             // Header for the Linux file system support
    #include <asm/uaccess.h>          // Required for the copy to user function
    #include <sys/types.h>
    

    And my Makefile

    obj-m = test.o
    
    all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
    clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
    

    I have tried to search for this file

     find /usr/include -name types.h
    

    Here are results

    /usr/include/sys/types.h
    /usr/include/libr/sdb/types.h
    /usr/include/rpc/types.h
    /usr/include/i386-linux-gnu/sys/types.h
    /usr/include/i386-linux-gnu/asm/types.h
    /usr/include/i386-linux-gnu/bits/types.h
    /usr/include/linux/iio/types.h
    /usr/include/linux/types.h
    /usr/include/x86_64-linux-gnu/sys/types.h
    /usr/include/x86_64-linux-gnu/asm/types.h
    /usr/include/x86_64-linux-gnu/bits/types.h
    /usr/include/asm-generic/types.h
    /usr/include/c++/5/parallel/types.h
    

    I tried to set it as #include "/usr/include/sys/types.h"

    but got following error

    /usr/include/sys/types.h:25:22: fatal error: features.h: No such file or directory
    compilation terminated.
    

    I am using Kali Linux(Debian) AMD64 platform

    Linux kali 4.5.0-kali1-amd64 #1 SMP Debian 4.5.5-1kali1 (2016-06-06) x86_64 GNU/Linux
    

    What is wrong ? Thanks

    SOLVED

    Sorry this was my fault, I made a typo in type and tried to include sys/types.h file, but it was not required at all all types are declared in /usr/src/linux-headers-4.5.0-kali1-common/include/linux/types.h in my case. Thanks everyone.