【问题标题】:compilation error fatal error: sys\types.h: No such file or directory #include <sys\types.h> [closed]编译错误致命错误:sys\types.h:没有这样的文件或目录#include <sys\types.h> [关闭]
【发布时间】:2016-04-06 21:43:30
【问题描述】:

我已经寻找并寻找解决方案。当然有这些链接暗示了一件事或另一件事:

Error :sys/types.h No such directory found

fatal error: sys/socket.h: No such file or directory on 32bit

Error :sys/types.h No such directory found

还有其他类似的链接。

让我告诉你错误,相关的 Makefile 语句,并向你展示我的包含目录结构。

错误

gcc -o obj/nmlflpth.o -std=c99 -Ilarc/include -Ilarc/modules/include -Ilarc/milesup -Ilarc/pftk -Ilarc/npsol -Ilarc/src -Ilarc/uih -Ilarc/util -Ilarc/uopt -Ilarc/pgm -Ilarc/navlrc -Ilarc/modules/production/common -Ilarc/src_test -Ilarc/gtest/include -c -O2 larc/uih/nmlflpth.c
larc/uih/nmlflpth.c:48:23: fatal error: sys\types.h: No such file or directory
#include <sys\types.h>

相关的 Makefile 语句

# list of all dirs with compilable C, C++ and F77 code
dirs    :=  larc/milesup \
            larc/pftk \
            larc/npsol \
            larc/src \
            larc/uih \
            larc/util \
            larc/uopt \
            larc/pgm \
            larc/navlrc \
            larc/modules/production/common

# list of dirs with include/header files
idirs   := larc/include larc/modules/include
idirs   += $(dirs)
idirs   += larc/gtest/include
ipaths  := $(addprefix -I, $(idirs))
cflags  := -std=c99 $(ipaths)
optflag := -O2

cdefines:= -DVERSION_BUILD_DATE="\"$(shell date)\"" \
       -DVERSION_VENDOR="\"$(VENDOR)\"" \
       -DVERSION_OSTYPE="\"$(OSTYPE)\"" \
       -DVERSION_HOST="\"$(HOST)\"" \
       -DVERSION_USER_NAME="\"$(USER)\"" \
       -DVERSION_VIEW_NAME="\"NONCLEARCASE\""   

$(cobjs): obj/%.o: %.c
    # $(CC) -o $@ $(cflags) -c $(optflag) $<
    @ -mkdir -p obj/
    @ $(CC) -o $@ $(cflags) $(cdefines) $(ipaths) -c $(optflag) $<

请注意: @ $(CC) -o $@ $(cflags) $(cdefines) $(ipaths) -c $(optflag) $

为什么?我没有线索。

包括 sys/types.h 的文件夹

这就是 gcc 正在寻找的:

$echo "#include <sys/types.h>" | gcc -E -x c - | grep types
# 1 "/usr/include/x86_64-linux-gnu/sys/types.h" 1 3 4
# 25 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 26 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/types.h" 1 3 4
# 27 "/usr/include/x86_64-linux-gnu/bits/types.h" 3 4
# 28 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4
# 121 "/usr/include/x86_64-linux-gnu/bits/types.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/typesizes.h" 1 3 4
# 122 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4
# 30 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 60 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 98 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 132 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 133 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 146 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 147 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 194 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 216 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 217 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 220 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 223 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 270 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 1 3 4
# 21 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4
# 22 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 2 3 4
# 60 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4
# 90 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4
# 124 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4
# 211 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4
# 271 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4

我的 types.h 有以下文件夹内容:

$ls /usr/include/x86_64-linux-gnu/sys |grep types.h
bitypes.h
types.h

ls /usr/include/sys |grep types.h
bitypes.h
types.h

来自 debian 包:

$ dpkg -S /usr/include/sys/types.h 
libc6-dev-amd64: /usr/include/sys/types.h
$ dpkg -S /usr/include/x86_64-linux-gnu/sys/types.h 
libc6-dev:amd64: /usr/include/x86_64-linux-gnu/sys/types.h

非常感谢您对此的任何帮助。谢谢!

【问题讨论】:

  • #include &lt;sys\types.h&gt; 错误可能是由于代码中的`\`而不是`/`引起的
  • 那里 IS 没有“sys\types.h”。这相当于“sys&lt;tab&gt;ypes.h”!你需要#include &lt;sys/types.h&gt;

标签: c compilation compiler-errors makefile


【解决方案1】:

你的意思是 #include &lt;sys/types.h&gt;不是#include &lt;sys\types.h&gt;

【讨论】:

  • 他写的有趣的事情$echo "#include &lt;sys/types.h&gt;" | gcc -E -x c - | grep types
  • @LuizEduardoF。我知道!但是话又说回来,我们都会不时犯愚蠢的错误,所以是的..
  • :(这是一个非常痛苦的观察结果
  • @torrho 每个人都会时不时地经历那个,所以别担心;-)
猜你喜欢
  • 1970-01-01
  • 2019-03-07
  • 1970-01-01
  • 1970-01-01
  • 2014-10-24
  • 2016-06-19
  • 2023-03-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多