我有一个通过 UDP 协议(protocol)发送数据的 linux 应用程序。它使用这些头文件:
#include <stdio.h>
/* standard C i/o facilities */
#include <stdlib.h>
/* needed for atoi() */
#include <unistd.h>
/* defines STDIN_FILENO, system calls,etc */
#include <sys/types.h> /* system data type definitions */
#include <sys/socket.h> /* socket specific definitions */
#include <netinet/in.h> /* INET constants and stuff */
#include <arpa/inet.h> /* IP address conversion stuff */
#include <netdb.h>
#include <string.h> /* for string and memset etc */
/* gethostbyname */
#include <iostream>
#include <fstream>
#include <opencv/highgui.h>
#include <opencv/cv.h>
#include <opencv/cxcore.h>
我想制作我的应用程序的 WIndows 版本。但是上面的一些头文件在 WIndows 中不工作,尤其是那些 UDP 的头文件。
我应该在 Windows (Visual Studio 2010) 中替换哪些头文件?
更新:
好的,所以我的标题现在看起来像这样:
#include <iostream>
#include <fstream>
#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <winsock2.h>
我在尝试编译时遇到此错误(以及许多其他类似错误):
Error 13 error C2011: 'fd_set' : 'struct' type redefinition c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winsock2.h 132 1 Client
最佳答案
在编译时,您需要使用 Winsock2.h
而不是 Unix header 。
在链接时,包含 ws2_32.lib
以提供到所需系统 DLL 的链接。
关于Windows 中 UDP 的 C++ 头文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4432989/