如何在我的Ubuntu的c文件中包含socket.h

时间:2011-05-11 01:35:53

标签: c ubuntu

这是我的a.c代码:

#include <stdio.h>
#include <socket.h>


int main(void)
{
    int count[4] = {[2] = 3  }, i;

    for (i = 0; i < 4; i++)
        printf("count[%d]=%d\n", i, count[i]);
    return 0;
}

当我编译它时,它会显示:

a.c:2: fatal error: socket.h: No such file or directory
compilation terminated.

那我该如何包含它/哪里可以下载呢?

2 个答案:

答案 0 :(得分:7)

应该是:

#include <sys/socket.h>

路径是相对于/ usr / include路径给出的。所以例如socket.h文件位于/usr/include/sys/socket.h下。如果您不知道,可以搜索它:

find /usr/include/ -name SEARCHED_HEADER.h

答案 1 :(得分:3)

#include <sys/socket.h>

下次尝试谷歌。