2010-05-17 92 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通常運行在不區分大小寫的文件系統上,所以即使給這些頭文件類似的名字也可能是危險的。