Windows(MSYS2)内置的OpenOCD无法创建套接字

问题描述 投票:0回答:1

我从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”选项调用configure脚本。

build configure openocd
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.