问题描述
我有一个通过 UDP 协议发送数据的 linux 应用程序.它使用这些头文件:
I have a linux applications which sends data over UDP protocol. It uses these header files:
#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 的.
I want to make a WIndows version of my app. But some of the above header files do not work in WIndows, especially those for UDP.
我应该在 Windows (Visual Studio 2010) 中替换哪些头文件?
Which header files should I substitute them for in Windows (Visual Studio 2010)?
更新:
好的,所以我的标题现在看起来像这样:
Ok, so my header now looks like this:
#include <iostream>
#include <fstream>
#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <winsock2.h>
我在尝试编译时收到此错误(以及许多其他类似错误):
I get this error when trying to compile (and many other similar errors):
Error 13 error C2011: 'fd_set' : 'struct' type redefinition c:program files (x86)microsoft sdkswindowsv7.0aincludewinsock2.h 132 1 Client
推荐答案
在编译时,您需要使用 Winsock2.h
而不是 Unix 头文件.
At compile-time, you need to use Winsock2.h
instead of the Unix headers.
在链接时,包含 ws2_32.lib
以提供到所需系统 DLL 的链接.
At link-time, include ws2_32.lib
to provide linkage to the required system DLL.
这篇关于Windows 中 UDP 的 C++ 头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!