Page 1 of 1

Error while compiling a UEFI application

Posted: Wed Jan 04, 2023 9:35 pm
by robin1201
Hello I am currently trying out a lot with gnu-efi and came up with the idea to output a png image on the screen. Now I have an error message when linking the efi application.

The following error:
ld: Build/main.o:(.bss+0x0): multiple definition of `stbi__g_failure_reason'; Build/Images/png.o:(.bss+0x0): first defined here
ld: Build/main.o: in function `stbi_zlib_decode_malloc_guesssize_headerflag':
main.c:(.text+0x201f): multiple definition of `stbi_zlib_decode_malloc_guesssize_headerflag'; Build/Images/png.o:png.c:(.text+0x201f): first defined here
ld: Build/main.o: in function `stbi__png_load':
main.c:(.text+0x4b8d): multiple definition of `stbi__png_load'; Build/Images/png.o:png.c:(.text+0x4b8d): first defined here
make: *** [Makefile:16: efi] Error 1
My Source code: https://github.com/rxbin1201/Bootloader

I hopy anyone can help me with my problem.

Re: Error while compiling a UEFI application

Posted: Wed Jan 04, 2023 10:08 pm
by Octocontrabass
According to the readme for your PNG decoder, you're using it incorrectly. You're supposed to define STB_IMAGE_IMPLEMENTATION only once, in the source file that will be compiled into the PNG decoder object file. You're defining it in every source file that includes png.h, which results in multiple copies of the PNG decoder and thus duplicate symbols.