2012-03-08 60 views
0

已添加#define _WINSOCKAPI_但仍构建失败。构建失败:winsock2.h文件未找到

/* 
* $PostgreSQL: pgsql/src/include/port/win32/sys/socket.h,v 1.7 2006/10/04 00:30:10 momjian Exp $ 
*/ 
#ifndef WIN32_SYS_SOCKET_H 
#define WIN32_SYS_SOCKET_H 

/* 
* Unfortunately, <wingdi.h> of VC++ also defines ERROR. 
* To avoid the conflict, we include <windows.h> here and undefine ERROR 
* immediately. 
* 
* Note: Don't include <wingdi.h> directly. It causes compile errors. 
*/ 
#define _WINSOCKAPI_ //added this line but no help 
#include <winsock2.h> 
#include <ws2tcpip.h> 
#include <windows.h> 

#undef ERROR 
#undef small 

/* Restore old ERROR value */ 
#ifdef PGERROR 
#define ERROR PGERROR 
#endif 

/* 
* we can't use the windows gai_strerror{AW} functions because 
* they are defined inline in the MS header files. So we'll use our 
* own 
*/ 
#undef gai_strerror 

#endif /* WIN32_SYS_SOCKET_H */ 

回答

0

尝试使用

#ifndef __APPLE__ ... #endif

然后,看看其他的编译错误,包括苹果特定的套接字文件,也根据BSD套接字工作。

+0

我应该在哪里发表上述声明? – Ava 2012-03-08 20:35:34

1

您正在尝试在绝对不是Windows的平台上编译Windows特定的头文件。我无法想象你期望这样做;不管它是什么,但它并不是。

+0

我想导入一个现有的项目。 – Ava 2012-03-08 20:36:01

+2

因此,请留下该文件。另外:如果项目是PostgreSQL,它的目的是从命令行构建,而不是从XCode构建。 – duskwuff 2012-03-08 20:51:13

相关问题