Hi,
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 is the terminal output:
make[1]: Entering directory `/home/hugh/wine-1.5.26/dlls/kernel32' [snip] ../../tools/winegcc/winegcc -B../../tools/winebuild --sysroot=../.. -fasynchronous-unwind-tables -shared ./kernel32.spec actctx.o atom.o change.o comm.o computername.o console.o cpu.o debugger.o editline.o environ.o except.o fiber.o file.o format_msg.o heap.o kernel_main.o lcformat.o locale.o lzexpand.o module.o nameprep.o oldconfig.o path.o powermgnt.o process.o profile.o resource.o string.o sync.o tape.o term.o thread.o time.o toolhelp.o version.o virtual.o volume.o wer.o locale_rc.res version.res winerror.res -nodefaultlibs -Wb,-F,KERNEL32.dll -Wl,--image-base,0x7b800000 -o kernel32.dll.so -lwinecrt0 -lntdll ../../libs/port/libwine_port.a console.o: In function `GetLargestConsoleWindowSize_helper': /home/hugh/wine-1.5.26/dlls/kernel32/console.c:1377: undefined reference to `SystemParametersInfoA' /usr/bin/ld: kernel32.dll.so: hidden symbol `SystemParametersInfoA' isn't defined /usr/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status winegcc: gcc failed make[1]: *** [kernel32.dll.so] Error 2
Unfortunately, my knowledge of C is terrible, so I'm not sure what to do from here. If someone could help me solve this, I'd appreciate it.
If it helps, I'm able to use winegcc to build a simple Windows executable using SystemParametersInfo without any problems.
Thank you in advance,
Hugh
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
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 actually the correct fix would be to transfer this computation to wineconsole (which already imports user32), but thats' not a really trivial task A+
-----Original Message----- From: Eric Pouech [mailto:eric.pouech@orange.fr] Sent: Wednesday, 27 March 2013 8:54 AM To: wine-devel@winehq.org Subject: Re: Linker error when improving GetLargestConsoleWindowSize
Ken Thomases wrote:
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
Eric Pouech wrote:
actually the correct fix would be to transfer this computation to wineconsole (which already imports user32), but thats' not a really trivial task
So, if wineconsole imports user32 to run console programs, that explains why a generic program using SystemParametersInfo or GetSystemMetrics is able to compile and run correctly, yes? For example:
--- #include <windows.h> #include <winuser.h> #include <stdio.h>
main(void) { RECT workarea;
SystemParametersInfo(SPI_GETWORKAREA, 0, &workarea, 0);
int screen_x = workarea.right; int screen_y = workarea.bottom;
printf("Your screen resolution is %d x %d pixels.\n", screen_x, screen_y); } --- Anyway, if I understand you correctly, the computations would need to be moved to programs/wineconsole (wineconsole.c).
Hugh
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@codeweavers.com] Sent: Tuesday, 26 March 2013 1:54 PM To: Hugh McMaster Cc: wine-devel@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