Linker error when improving GetLargestConsoleWindowSize

Hugh McMaster hugh.mcmaster at masterindexing.com
Tue Mar 26 18:36:27 CDT 2013


Hi Ken,

Thank you for your explanation. I now have a far better understanding of the relationship between kernel32 and user32.  The information was actually on MSDN, but I didn't really pay too much attention to the prerequisites for using calls such as SystemParametersInfo.

I'm now going to substitute SystemParametersInfo with display information supplied by X11.  So far, this method is working fine.  The 'make' function has built and linked kernel32.dll with no errors or warnings.

Hugh

-----Original Message-----
From: Ken Thomases [mailto:ken at codeweavers.com] 
Sent: Tuesday, 26 March 2013 1:54 PM
To: Hugh McMaster
Cc: wine-devel at winehq.org
Subject: Re: Linker error when improving GetLargestConsoleWindowSize

On Mar 25, 2013, at 8:51 PM, Hugh McMaster wrote:

> I've written a function to determine the largest possible screen buffer that wineconsole is able to display. This function replaces the hard-coded constants listed in both instances of GetLargestConsoleWindowSize in dlls/kernel32/console.c.
> 
> [snip]
> #include <windows.h>
> #include <winuser.h>
> 
> [snip]
> 
> COORD GetLargestConsoleWindowSize_helper(HANDLE hConsoleOutput) {
>    RECT workarea;
>    COORD console_fontsize;
>    COORD max_console;
> 
>    SystemParametersInfoA(SPI_GETWORKAREA, 0, &workarea, 0);
>    console_fontsize = GetConsoleFontSize(hConsoleOutput, 0);
> 
>    max_console.X = (workarea.right / console_fontsize.X) - 6;
>    max_console.Y = (workarea.bottom / console_fontsize.Y) - 6;
> 
>    return max_console;
> }
> 
> While dlls/kernel32/console.c compiles, I'm having trouble with the final compile-time linking.  It seems that SystemParametersInfoA is an undefined reference, but windows.h and winuser.h are included in console.c.

This won't be able to work.  The linker error is telling you, effectively, that you're not importing user32.  However, kernel32 can't import user32.  Kernel32 is at a lower level than user32.  And a console program especially can't rely on user32 being loaded and initialized to satisfy the request you're making.

Regards,
Ken





More information about the wine-devel mailing list