mingw-w64 - 使用带有 Mingw-w64 的 wininet 编译 c 源的链接器错误
问题描述
我在 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
任何人都可以帮忙吗?
解决方案
您应该Wininet.lib
按照InternetOpenA
文档所述链接(请参阅要求部分)。
推荐阅读
- sql - SQL 从滚动 ID 生成唯一 ID
- javascript - 如何将服务器端生成的新页面加载到 PhoneGap 或 Cordova 应用程序中?
- r - R falsely identifying abundance data as presence/absence data (fossil package)
- java - 用 replaceAll 删除部分字符串
- reactjs - 在 React 中映射组件后如何渲染组件集合
- python - altair 删除或抑制自动生成的图例
- c++ - 为什么 C++ 按位 AND 运算符对不同大小的操作数会表现得像这样?
- sql-server - SSIS - 合并xml的非链接部分
- google-analytics-filters - 在 GA 正则表达式中过滤 URL 以获取自定义 ID
- oracle - 带有跳过选项的 Oracle 加载程序