Thread: GetFileSizeEx undefined reference in MingW

  1. #1
    Registered User
    Join Date
    Jun 2016
    Posts
    3

    GetFileSizeEx undefined reference in MingW

    Hi guys,
    I'm having problems with MingW gcc compiler.
    It looks like this:
    Code:
    C:\Users\xxx\AppData\Local\Temp\ccorppwa.o:vt.c:(.text+0x26e): undefined reference to `GetFileSizeEx'
    collect2.exe: error: ld returned 1 exit status
    I tried several solutions such as:
    Code:
    #pragma comment (lib, kernel32)
    gcc -lkernel32
    #include <windows.h> as well as winbase.h

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    Your second solution should've worked. Are you sure you used it correctly? Are you using an IDE, if yes: which?
    Devoted my life to programming...

  3. #3
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    This is a very common MinGW problem unfortunately (many headaches spent looking at crap like this). You have to set the correct values to the WINVER and/or _WIN32_WINNT macros before including Windows headers, and sometimes the order of inclusion matters as well.

    Quick google: winapi - WIN API GetFileSizeEx() function, was not declared in this scope - Stack Overflow

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. MinGW undefined reference
    By Amera in forum C Programming
    Replies: 4
    Last Post: 08-15-2010, 02:10 PM
  2. Help! Undefined Reference
    By halo3 in forum C++ Programming
    Replies: 10
    Last Post: 08-25-2009, 12:43 PM
  3. mingw / undefined references
    By pheres in forum C++ Programming
    Replies: 2
    Last Post: 09-18-2007, 05:14 PM
  4. Replies: 3
    Last Post: 04-16-2007, 12:02 PM
  5. Mingw undefined references.
    By Blackroot in forum Tech Board
    Replies: 2
    Last Post: 08-29-2006, 03:21 AM

Tags for this Thread