【问题标题】:Windows (MSYS2) built OpenOCD fails to create socketsWindows (MSYS2) 构建的 OpenOCD 无法创建套接字
【发布时间】:2018-09-14 16:13:33
【问题描述】:

我已经从 https://github.com/gnu-mcu-eclipse/openocd 克隆了 openOCD 并使用 MSYS2 (MINGW32) shell 构建它。构建顺利通过,当尝试执行时,它失败并给出错误“错误:创建套接字时出错”。

我启用了调试选项,发现它来自 server.c 文件。 我正在使用 64 位 Windows 10 PC 进行构建。

错误来自下面的代码段,

    c->fd = socket(AF_INET, SOCK_STREAM, 0);
    if (c->fd == -1) {
        LOG_ERROR("error creating socket: %s", strerror(errno));
        exit(-1);
    }

我注意到必须为 WIN32 构建启用的宏尚未启用,如果启用,该宏会调用 Windows 特定的套接字函数。

int server_preinit(void)
{
/* this currently only calls WSAStartup on native win32 systems
 * before any socket operations are performed.
 * This is an issue if you call init in your config script */

#ifdef _WIN32
WORD wVersionRequested;
WSADATA wsaData;

wVersionRequested = MAKEWORD(2, 2);

if (WSAStartup(wVersionRequested, &wsaData) != 0) {
    LOG_ERROR("Failed to Open Winsock");
    exit(-1);
}

/* register ctrl-c handler */
SetConsoleCtrlHandler(ControlHandler, TRUE);

signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
signal(SIGBREAK, sig_handler);
signal(SIGABRT, sig_handler);
#endif

return ERROR_OK;
}

我手动启用了这个宏,编译失败。

谁能帮助确定我在配置 openOCD 时是否遗漏了什么? 我仅通过“--disable-werror”选项调用配置脚本。

【问题讨论】:

    标签: build configure openocd


    【解决方案1】:

    您需要使用 MinGW 编译器而不是 MSYS 编译器构建 OpenOCD。您可以尝试使用来自this repo 的脚本。 该链接还描述了如何在 MSYS 下安装 MinGW。

    【讨论】:

      猜你喜欢
      • 2011-01-01
      • 2022-01-13
      • 2022-01-18
      • 1970-01-01
      • 2015-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-06
      相关资源
      最近更新 更多