Where is sys/types.h located?

来源:互联网 发布:netcat端口转发 编辑:程序博客网 时间:2024/06/05 09:30

http://stackoverflow.com/questions/11823063/where-is-sys-types-h-located

Where is sys/types.h located?

up vote6down votefavorite
5

I just found out that the <stdlib.h> and <stdio.h> headers are located in the /usr/includefolder 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?

share|improve this question
 
 
No, header files must be present. Maybe look in /usr/local/include. –  user529758 Aug 6 '12 at 5:49
7 
echo "#include <sys/types.h>" | gcc -E -x c - | grep types to see where it is picking it up from–  Mat Aug 6 '12 at 5:49
 
@H2CO3 Thanks for pointing it out –  mko Aug 6 '12 at 5:53
 
@Mat It works, I find it out, BTW what's the last parameter - used for? –  mko Aug 6 '12 at 5:55
 
Perhaps this should be asked at askubuntu or serverfault? –  Paulo Scardine Aug 6 '12 at 5:56
show 7 more comments

4 Answers

activeoldestvotes
up vote20down voteaccepted

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.

share|improve this answer
 
 
Wow, what's an answer, I've learned so much, and the gcc way works, now I found the file –  mko Aug 6 '12 at 6:13
 
+1 for explain the flags –  mko Aug 6 '12 at 6:14
 
@yozloy, just out of interest, where was it? –  paxdiablo Aug 6 '12 at 6:21
 
On Ubuntu 12, I found this at /usr/include/linux/types.h. –  jmervine May 30 '13 at 0:55
add comment
up vote2down vote

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: Nosuch 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
share|improve this answer
 
1 
if it's just for sys/types.h I think build-essential should do the trick. –  Lester Cheung Dec 16 '13 at 5:18
 
On linux mint 16: sudo apt-get install build-essential was enough. –  Chris Weber Mar 18 at 20:40
add comment
up vote0down vote

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

share|improve this answer
 add comment
up vote0down vote

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.

share|improve this answer
 add comment
0 0