Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is sys/types.h located?

Tags:

I just found out that the <stdlib.h> and <stdio.h> headers are located in the /usr/include folder in Ubuntu server, but I don't find sys/types.h.

And I start to suspect the compiler won't actually use the header file in the /usr/include folder.

Is this true, and where is the file located?

like image 708
mko Avatar asked Aug 06 '12 05:08

mko


People also ask

What is SYS type H?

The sys/types. h header file defines a collection of typedef symbols and structures.

Where are SYS headers?

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


2 Answers

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 execute:

find /usr/include -name types.h find / -name types.h # if not found by one above 

However, keep in mind that the development stuff may not even be installed on a server. Unless it's a server for a compiler farm, it wouldn't surprise me if the compiler and a bunch of other stuff was not part of the default install.

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.

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 leaving the ones that are likely to contain the location of the included file.

like image 88
paxdiablo Avatar answered Mar 06 '23 06:03

paxdiablo


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 
like image 26
rascaL raajA Avatar answered Mar 06 '23 08:03

rascaL raajA