Page 1 of 1

Mingw GCC Undefined references to LIB EFI

Posted: Wed Dec 13, 2023 5:57 am
by GreanBean
For the past couple days I've been trying to get Mingw GCC Working with GNU-EFI, Whenever I try to compile using function from libefi.h I get errors:

Code: Select all

/usr/lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld: /tmp/ccUyeC4u.o:main.c:(.text+0x1c): undefined reference to `InitializeLib'
/usr/lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld: /tmp/ccUyeC4u.o:main.c:(.text+0x2b): undefined reference to `Print'
This is my Makefile

Code: Select all

gcc:
	x86_64-w64-mingw32-gcc main.c \
	-std=c17 \
	-Wall \
	-Wpedantic \
	-mno-red-zone \
	-ffreestanding \
	-nostdlib \
	-I /usr/include/efi \
	-I /usr/include/efi/x86_64 \
	-L /usr/lib
	-Wl,--subsystem,10 \
	-e efi_main \
	-o main.efi

Re: Mingw GCC Undefined references to LIB EFI

Posted: Tue Feb 13, 2024 2:21 am
by klange
I apologize for the delay in approving your post.

GNU-EFI is not intended to be used with Mingw: It is a build system for using an ELF toolchain to create EFI binaries.

You are referencing library functions from the included EFILIB - if you want to use these functions outside of GNU-EFI, you must build it separately from source and then link with it.