wininet/gcc - how to?

This is a discussion on wininet/gcc - how to? within the Windows Programming forums, part of the Platform Specific Boards category; Hello, I'm trying to use wininet with gcc. This simple example program compiles but does not link ("undefined reference", see ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    57

    wininet/gcc - how to?

    Hello, I'm trying to use wininet with gcc. This simple example program compiles but does not link ("undefined reference", see below).

    Thanks for all help.

    Code:
    // compile/link:
    // gcc -c test.c -o test.o
    // gcc -mwindows -lwininet test.o -o test.exe
    
    #include <windows.h>
    #include <wininet.h>
    
    HINTERNET bay;
    
    //-----------------------------------------------------------------------------
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    	LPSTR lpCmdLine, int nCmdShow)
    {
       bay=InternetOpen(0,INTERNET_OPEN_TYPE_DIRECT,0,0,0);
    }
    The command line results:
    Code:
    C:\gcc\Progs\>gcc -c test.c -o test.o
    
    C:\gcc\Progs\>gcc -mwindows -lwininet test.o -o test.exe
    test.o(.text+0x2e):test.c: undefined reference to `InternetOpenA@20'
    
    C:\gcc\Progs\>

  2. #2
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Maybe use the path to your wininet library file instead of -lwininet...

  3. #3
    Super Moderator Harbinger's Avatar
    Join Date
    Nov 2004
    Posts
    74
    Maybe put -lwininet after the object files....

  4. #4
    Registered User
    Join Date
    Sep 2004
    Posts
    57
    Quote Originally Posted by Harbinger
    Maybe put -lwininet after the object files....
    That worked! Thanks!

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21