Error while compiling a UEFI application

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
robin1201
Posts: 17
Joined: Sun Aug 22, 2021 3:11 pm
Location: Germany

Error while compiling a UEFI application

Post 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.
Octocontrabass
Member
Member
Posts: 5562
Joined: Mon Mar 25, 2013 7:01 pm

Re: Error while compiling a UEFI application

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