Search code examples
cwindowswinapimingw32

undefined reference to 'SetCurrentConsoleFontEx'?


When compiling this code:

PCONSOLE_FONT_INFOEX Font_Info;
//Adjust heights
Font_Info.dwFontSize.X = 9;
Font_Info.dwFontSize.Y = 9;
SetCurrentConsoleFontEx( StdHandle, FALSE, Font_Info);

GCC reports

undefined reference to 'SetCurrentConsoleFontEx'

But MSDN says that the header is #include<windows.h>

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686200(v=vs.85).aspx

Why? And how to resolve this problem ? THANKS.

PS,

I couldn't find any declaration in wincon.h and windows.h


Solution

  • This would not be the first time a function is missing from MinGW's SDK, and especially not a recent function like SetCurrentConsoleFontEx which is only exposed from Vista onwards.

    Your libkernel32.a is too old for it; if you want to use this function from MinGW, you may need to access it dynamically instead.