Compiling GRUB on Cygwin (64 bit)

2.2k Views Asked by At

I'm using 64 bit Cygwin on Windows 8.1 for some basic operating system development. I'd like to use the utilities that come with GRUB 2.00 (such as mkrescue and mkimage) as my kernel is Multiboot 2 compatible and I'm booting from CD.

I have no problems compiling all of the tools I need in Cygwin except for GRUB, which spits out the following errors:

libgrubkern.a(libgrubkern_a-getroot.o):getroot.c:(.text+0x215): undefined reference to `cygwin_conv_to_full_posix_path'
libgrubkern.a(libgrubkern_a-getroot.o):getroot.c:(.text+0x215): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `cygwin_conv_to_full_posix_path'
libgrubkern.a(libgrubkern_a-getroot.o):getroot.c:(.text+0x228): undefined reference to `cygwin_conv_to_full_win32_path'
libgrubkern.a(libgrubkern_a-getroot.o):getroot.c:(.text+0x228): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `cygwin_conv_to_full_win32_path'
collect2: error: ld returned 1 exit status
Makefile:16816: recipe for target 'grub-mkrelpath.exe' failed

This is obviously something to do with the conversion in Cygwin between Windows and Posix-style paths. Slightly frustrating because even something as big as the GCC cross-compiler were compilable with no such issue.

I have Googled the exact error, but get no hits in relation to GRUB. Does anyone have a solution for this?

Adam

2

There are 2 best solutions below

3
On BEST ANSWER

Looks like I'm on a similar road to the one you're on. From what I've seen, that line of path functions was deprecated and removed, being replaced by a newer approach. I was able to get it to continue compiling, but hit a different, but probably unrelated error.

In the file util/getroot.c in the function grub_find_device() I replaced:

cygwin_conv_to_full_posix_path (path, fullpath);
cygwin_conv_to_full_win32_path (fullpath, winpath);

With the following:

cygwin_conv_path(CCP_WIN_A_TO_POSIX, path, fullpath, PATH_MAX);
cygwin_conv_path(CCP_POSIX_TO_WIN_A, fullpath, winpath, PATH_MAX);

Unfortunately I ran into this next:

TARGET_OBJ2ELF=../grub-pe2elf sh genmod.sh moddep.lst regexp.module.exe regexp.mod
./../grub-pe2elf: error: invalid symbol.

Another (less desirable, but maybe less irritating) solution I've found mentioned to this issue is trying to find an older version of Cygwin, or a 32 bit version of Cygwin that works with the version of GRUB you want. Unfortunately, that'd probably mean rebuilding all your tools again.

Either way, I'm going to see if I can fix this new problem, and if I do I'll let you know.

0
On

It's a long time since I posted the original question but I've just found it again. Just to say that the long-term answer for me turned out to be switching away from Cygwin and I'm now using Bash on Ubuntu on Windows which has been much more successful for all the utilities I'm using.