0
votes

I have a problem compiling c-source on windows. I use functions of wininet and got a linker error.
I use this version g++.exe (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0

sample code:

#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;
}

the compile statement wirh error:

"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

Can anyone help?

1

1 Answers

0
votes

You should link with Wininet.lib as InternetOpenA documentation says (see Requirements part).