Mingw GCC Undefined references to LIB EFI

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
GreanBean
Posts: 1
Joined: Tue Dec 12, 2023 9:36 pm
Libera.chat IRC: GreanBean

Mingw GCC Undefined references to LIB EFI

Post 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
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: Mingw GCC Undefined references to LIB EFI

Post 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.
Post Reply