Linker error when improving GetLargestConsoleWindowSize

Hugh McMaster hugh.mcmaster at masterindexing.com
Mon Mar 25 20:51:44 CDT 2013


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



More information about the wine-devel mailing list