Where is sys/types.h located?

前端 未结 5 1255
别跟我提以往
别跟我提以往 2021-01-30 09:37

I just found out that the and headers are located in the /usr/include folder in Ubuntu server, but I don\

相关标签:
5条回答
  • 2021-01-30 09:52

    Just for future reference, I ran into this problem on my debian machine, and it turned out that in my case

    $ apt-file find /usr/include/sys/types.h
    libc6-dev-i386: /usr/include/sys/types.h
    

    libc6-dev-i386 is the package I seemingly need to install

    0 讨论(0)
  • 2021-01-30 10:10

    My Debian box (and hopefully Ubuntu haven't butchered it too much in their zeal) has it in /usr/include/sys/types.h.

    Your best bet is to first execute:

    find /usr/include -name types.h
    

    then:

    find / -name types.h
    

    if you don't find it in the first one.

    However, keep in mind that the development stuff may not even be installed. I would imaging a server box is meant to be used as a server and it wouldn't surprise me if the compiler and a bunch of other stuff was not part of the default install (but it would have a lot of server things like ftpd or Apache and so on).

    If the compiler is locating it somewhere and you just don't know where, you can use something like:

    echo "#include <sys/types.h>" | gcc -E -x c - | grep /types.h
    

    to find out where it's getting it from.

    Or:

    echo "#include <stdio.h>" | gcc -E -x c - | grep /stdio.h
    

    for the other header you're worried about.

    Aside: That gcc command line stops after the pre-processing phase (-E), forces the file to be treated as C source code (-x c) and retrieves the program from standard input (-), in this case from the echo statement.

    The final grep just strips out the unimportant lines.

    0 讨论(0)
  • 2021-01-30 10:11

    If you have locate command available you can simply use locate:

    -bash-3.2$ locate sys/types.h
    /usr/include/sys/types.h
    /usr/lib/syslinux/com32/include/sys/types.h
    -bash-3.2$
    

    It's the quickest and simplest way to do it.

    0 讨论(0)
  • 2021-01-30 10:14

    On Linux, types.h should be in /usr/include/sys/types.h.

    0 讨论(0)
  • 2021-01-30 10:16

    The file sys/types.h is located at the /usr/include/sys/types.h

    if u get this kind of Fatal Error:

    .../linux/linux_types.h:146:38: fatal error: /usr/include/sys/types.h: No
    such file or directory
    

    Fix by using the following code:

    sudo apt-get install build-essential flex libelf-dev libc6-dev-amd64 binutils-dev libdwarf-dev
    
    0 讨论(0)
提交回复
热议问题