【问题标题】:Winsock2.h seems to be missing from mingw?mingw 中似乎缺少 Winsock2.h?
【发布时间】:2016-11-21 20:57:30
【问题描述】:

我在我的 Arch Linux 发行版上安装了 mingw,以便交叉编译 Windows 应用程序。一切似乎都很好,除非我包含 Winsock2:

x86_64-w64-mingw32-gcc -c -Wall  -o tcp.o tcp.c
tcp.c:14:24: fatal error: Winsock2.h: No such file or directory
#include <Winsock2.h>

我错过了什么包裹?

【问题讨论】:

  • 尝试安装 mingw-w64-headers-git-4.0.rc1.r183.g5e2e73b-1-any.pkg.tar.xz 或同等产品。我在存档中达到顶峰,看到了 winsock.h 和 winsock2.h。

标签: c linux windows mingw cross-compiling


【解决方案1】:

问题是在 linux 中,文件路径是区分大小写的。在 Windows 上,您可以:

#include <Winsock2.h>

而实际文件是C:/Path/To/Include/winsock2.h

在 linux 上你必须这样做

#include <winsock2.h>

【讨论】:

    猜你喜欢
    • 2014-05-09
    • 1970-01-01
    • 2017-03-23
    • 1970-01-01
    • 2014-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-24
    相关资源
    最近更新 更多