Kevin Dong
Kevin Dong

Reputation: 5359

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

Upvotes: 0

Views: 1193

Answers (2)

Medinoc
Medinoc

Reputation: 6608

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.

Upvotes: 1

jcm
jcm

Reputation: 2578

Undefiend reference refers to a linkage problem. Definition may be in windows.h but you need to link to the appropriate library (Kernel32.lib) to generate final binary.

Upvotes: 0

Related Questions