ajxs / uefi-elf-bootloader

UEFI ELF Bootloader example
GNU General Public License v3.0
91 stars 12 forks source link

Build error because of multiple definition in Arch Linux #5

Closed jafarlihi closed 1 year ago

jafarlihi commented 1 year ago

I'm attempting to run run but I get these errors:

ld: src/error.o:(.bss+0x0): multiple definition of `graphics_service'; src/elf.o:(.bss+0x0): first defined here
ld: src/error.o:(.bss+0x10): multiple definition of `file_system_service'; src/elf.o:(.bss+0x10): first defined here
ld: src/error.o:(.bss+0x18): multiple definition of `serial_service'; src/elf.o:(.bss+0x18): first defined here
ld: src/fs.o:(.bss+0x0): multiple definition of `graphics_service'; src/elf.o:(.bss+0x0): first defined here
ld: src/fs.o:(.bss+0x10): multiple definition of `file_system_service'; src/elf.o:(.bss+0x10): first defined here
ld: src/fs.o:(.bss+0x18): multiple definition of `serial_service'; src/elf.o:(.bss+0x18): first defined here
ld: src/graphics.o:(.bss+0x0): multiple definition of `graphics_service'; src/elf.o:(.bss+0x0): first defined here
ld: src/graphics.o:(.bss+0x10): multiple definition of `file_system_service'; src/elf.o:(.bss+0x10): first defined here
ld: src/graphics.o:(.bss+0x18): multiple definition of `serial_service'; src/elf.o:(.bss+0x18): first defined here
ld: src/loader.o:(.bss+0x0): multiple definition of `graphics_service'; src/elf.o:(.bss+0x0): first defined here
ld: src/loader.o:(.bss+0x10): multiple definition of `file_system_service'; src/elf.o:(.bss+0x10): first defined here
ld: src/loader.o:(.bss+0x18): multiple definition of `serial_service'; src/elf.o:(.bss+0x18): first defined here
ld: src/main.o:(.bss+0x0): multiple definition of `graphics_service'; src/elf.o:(.bss+0x0): first defined here
ld: src/main.o:(.bss+0x10): multiple definition of `file_system_service'; src/elf.o:(.bss+0x10): first defined here
ld: src/main.o:(.bss+0x18): multiple definition of `serial_service'; src/elf.o:(.bss+0x18): first defined here
ld: src/serial.o:(.bss+0x0): multiple definition of `graphics_service'; src/elf.o:(.bss+0x0): first defined here
ld: src/serial.o:(.bss+0x10): multiple definition of `file_system_service'; src/elf.o:(.bss+0x10): first defined here
ld: src/serial.o:(.bss+0x18): multiple definition of `serial_service'; src/elf.o:(.bss+0x18): first defined here
make[1]: *** [makefile:85: build/bootx64.so] Error 1
make[1]: Leaving directory '/home/user/uefi/uefi-elf-bootloader/src/bootloader'
make: *** [makefile:65: bootloader/build/bootx64.efi] Error 2
make: Leaving directory '/home/user/uefi/uefi-elf-bootloader/src'

I've got GCC 12.1.0 x86_64 ELF cross-compiler with binutils 2.38. GNU EFI and OVMF are latest ones from Arch repositories.

Am I doing something wrong?

ajxs commented 1 year ago

You're not doing anything wrong! The mistake was mine. For some reason I had mistakenly defined some variables in a header file. Earlier versions of GCC were much less strict about duplicate definitions. I've added an -fno-common directive to the build, which surfaced the errors on my version of GCC. I've moved the variable definitions. Can you pull the latest commit, and let me know if this resolves the issue? Thank you for bringing this to my attention!

jafarlihi commented 1 year ago

It works now, thanks!