2010-05-17 54 views
2

我想,当我运行make文件问题compiliing使用cygwin的

g++ -DHAVE_CONFIG_H -I. -I.. -I.. -Wall -Wextra -Werror -g -O2 -MT libcommon_a Fcntl.o -MD -MP -MF .deps/libcommon_a-Fcntl.Tpo -c -o libcommon_a-Fcntl.o `test -f 'Fcntl.cpp' || echo './'`Fcntl.cpp 
Fcntl.cpp: In function int setCloexec(int): 
Fcntl.cpp:8: error: 'F_GETFD' was not declared in this scope 
Fcntl.cpp:8: error: 'fcntl' was not declared in this scope 
Fcntl.cpp:11: error: 'FD_CLOEXEC' was not declared in this scope 
Fcntl.cpp:12: error: 'F_SETFD' was not declared in this scope 
make[4]: *** [libcommon_a-Fcntl.o] Error 1 
make[4]: Leaving directory `/abyss-1.1.2/Common' 
make[3]: *** [all-recursive] Error 1 
make[3]: Leaving directory `/abyss-1.1.2' 
make[2]: *** [all] Error 2 
make[2]: Leaving directory `/abyss-1.1.2' 
make[1]: *** [.build-conf] Error 2 
make[1]: Leaving directory `/cygdrive/c/Users/Martin/Documents/NetBeansProjects/abyss-1.1.2_1' 
make: *** [.build-impl] Error 2 

问题文件是编译在Cygwin的一些源代码(在Windows 7) 并得到以下错误的C++代码: -

#include "Fcntl.h" 
#include <fcntl.h> 


/* Set the FD_CLOEXEC flag of the specified file descriptor. */ 
int setCloexec(int fd) 
{ 
int flags = fcntl(fd, F_GETFD, 0); 
if (flags == -1) 
    return -1; 
flags |= FD_CLOEXEC; 
return fcntl(fd, F_SETFD, flags); 
} 

我不明白是怎么回事, 文件fcntl.h可用,它说varaiables在此范围内 没有宣布不给一个错误,当我编译自身文件

任何帮助,将不胜感激

非常感谢

+1

可能是因为名称冲突,就像在win'fcntl.h'和'Fcntl.h'指向相同的文件和(我不认为是这种情况,但stil ...)你可能是实际上包括相同的文件 - 请检查您的包含目录设置。 – 2010-05-17 21:24:58

回答

1

我没有内置事情Cygwin的,所以这可能是关闭基地,但考虑到你正在构建在Windows上,它有一个不区分大小写的文件系统,你确定编译器能够区分你的头文件Fcntl.h和系统头文件fcntl.h?它可能只是包含您的标题两次,并且永远不会获取系统标题。

+0

你是目标。 FAT32和NTFS是保留大小写的,但不区分大小写。因此,你不能在同一个目录下有Makefile和makefile,因为它们会被认为是不明确的。或者,在这种情况下,当搜索“Fcntl.h”时,它会发现系统就像搜索那样。您将要将源目录中的Fcntl.h重命名为myFcntl.h,并适当调整包含。 (让系统独立于fcntl.h。) – 2010-05-17 21:27:49

1

这些陈述与那些#include有什么关系?看起来你的项目中有一个名为Fcntl.h的头文件,对吗?它里面有警卫吗?如果是这样,也许你不小心使用了与内置标题相同的警卫,结果没有得到它的内容。 Cygwin通常运行在不区分大小写的文件系统上,所以即使给这些头文件类似的名字也可能是危险的。