Correction: 1. if a .LIB is passed to the linker instead, the linker searches the .LIB for a particular symbol (e.g. function, data). The specific .OBJ module that holds that particular symbol, is linked to the target.EFI. (the linker creates an link-error, like yours, if one or more symbol-name/s from that particular NON-one-definition-rule.OBJ is already present in the target.EFI) ________________________________ From: devel@edk2.groups.io on behalf of Kilian Kegel Sent: Wednesday, May 25, 2022 7:20:26 PM To: devel@edk2.groups.io ; xzavierpower@gmail.com Subject: Re: [edk2-devel] including redfish libs results in multiple definitions of symbols Hi xp, your build failure is 1. the result of a “link-all” mechanism or 2. the result of a library construction flaw that is commonly used in EDK2. or both Let me explain the theory: 1. an .OBJ file is created by the compiler for each .C source code file an .OBJ is considered as atomic, it can not be split into smaller pieces (except with newer compiler switches) 1. a “library“ .LIB is a collection of one or more of such .OBJ files 2. if an .OBJ is passed to linker, it is _always_ linked into the target.EFI (the linker creates an link-error, like yours, if that particular symbol-name is already present in the target.EFI) One definition rule: https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk2005?view=msvc-170 1. if an .LIB is passed to the linker instead, the linker searches the .LIB for a particular symbol (e.g. function, data). The specific .OBJ module that holds that particular symbol, is linked to the target.EFI. (the linker creates an link-error, like yours, if that particular symbol-name is already present in the target.EFI) One definition rule: https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk2005?view=msvc-170 1. to prevent such error each .OBJ of a library can hold only one single symbol, one function or one data. Only in that case the linker is able to pickup each single symbol from the library and bind it into the target.EFI without any conflict. This is also explained here: https://github.com/tianocore/edk2-staging/tree/CdePkg/blogs/2021-12-19#redfishcrtlib-conflicts-with-cdepkg-by-design Best regards, Kilian ________________________________ From: devel@edk2.groups.io on behalf of M.T. Sent: Wednesday, May 25, 2022 6:23:02 PM To: devel@edk2.groups.io Subject: [edk2-devel] including redfish libs results in multiple definitions of symbols Hello I'm working on a small UEFI shell app. I was hoping to make use of the JsonLib found in the Redfish Package. When I include the Redfish JsonLib and it's dependencies: JsonLib|RedfishPkg/Library/JsonLib/JsonLib.inf Ucs2Utf8Lib|RedfishPkg/Library/BaseUcs2Utf8Lib/BaseUcs2Utf8Lib.inf RedfishCrtLib|RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.inf BaseSortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf BaseSortLib has symbol clashes with SortLib resulting in the following: /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuickSort': (.text+0x0): multiple definition of `PerformQuickSort'; BaseSortLib.obj (symbol from plugin):(.text+0x0): first defined here /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuickSort': (.text+0x0): multiple definition of `DevicePathCompare'; BaseSortLib.obj (symbol from plugin):(.text+0x0): first defined here /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuickSort': (.text+0x0): multiple definition of `StringNoCaseCompare'; BaseSortLib.obj (symbol from plugin):(.text+0x0): first defined here /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuickSort': (.text+0x0): multiple definition of `StringCompare'; BaseSortLib.obj (symbol from plugin):(.text+0x0): first defined here I need SortLib for UEFIShell dependencies, and I need BaseSortLib for JsonLib. Is there some way around this? Or is Redfish meant to be standalone? Thank you in advance xp