【问题标题】:Linker error compiling c-source using wininet with Mingw-w64使用带有 Mingw-w64 的 wininet 编译 c 源的链接器错误
【发布时间】:2021-05-23 05:34:55
【问题描述】:

我在 Windows 上编译 c 源代码时遇到问题。我使用了 wininet 的函数,但出现了链接器错误。
我使用这个版本 g++.exe (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0

示例代码:

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <wininet.h>


int main (int argc, char **argv) 
{
    InternetOpen("WebReader", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 ); 
    return 0;
}

编译语句出现错误:

"C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin\g++.exe" -lwininet -g test.c -o test.exe
C:\Users\peter\AppData\Local\Temp\ccfXocKI.o: In function `main':
D:\source\mingw\ShellHost/test.c:9: undefined reference to `_imp__InternetOpenA@20'
collect2.exe: error: ld returned 1 exit status

谁能帮忙?

【问题讨论】:

标签: mingw-w64


【解决方案1】:

您应该将Wininet.lib 链接为InternetOpenA documentation says(请参阅要求部分)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-04
    • 1970-01-01
    相关资源
    最近更新 更多