0

So I just started writing a program, so excuse the unused variables etc. but I'm having this problem that the InternetGetConnectedState function is not found in any of the imports.

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

int CheckConnection(){
    int y = InternetGetConnectedState(0,0);
    return y;
}

int main(int argc, const char **argv, const char **envp){
    int x;

    return 0;
}

The error I am getting is "undefined reference to 'InternetGetConnectedState@8' ". I thought this function was included to wininet.h? https://msdn.microsoft.com/en-us/library/windows/desktop/aa384702(v=vs.85).aspx

Rafas
  • 103
  • 1
  • 2
  • 7
  • You also need to link against `Wininet(.lib)`. How to do this depends on what compiler you're using. With GCC try appending `-lwininet` on the command line. – Kninnug Jul 19 '16 at 20:15
  • Did you add the library to your dependencies? `#pragma comment(lib, "wininet.lib)` in your source file is one way to do it when using Visual Studio. – Retired Ninja Jul 19 '16 at 20:15

0 Answers0