From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) by mx.groups.io with SMTP id smtpd.web10.15965.1653538048395996939 for ; Wed, 25 May 2022 21:07:28 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hRpiP4TJ; spf=pass (domain: gmail.com, ip: 209.85.166.175, mailfrom: harlydavidsen@gmail.com) Received: by mail-il1-f175.google.com with SMTP id j15so356063ilo.5 for ; Wed, 25 May 2022 21:07:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:disposition-notification-to:in-reply-to :content-transfer-encoding; bh=bxeMzKxgZ0Eozk4TenAUr9NC7yA+1A+L0XtoFFuD2G4=; b=hRpiP4TJ5pTMAXqJCeM+cSl8fRIE7FTIrx4iHEXaZs7Vv9u/zui6oj9El2sHfwRFsX KLieN4mBjqbY6MIz7rPk+7u0K7VWiJeCPB7Xhu1PL2kexCs4D75dzbI5XUTaDqFEzSe+ Ge++9+a7bTuvGY6bWovb9rQUZcVWr9KST91zYwNdiBsD2nE/NWWIrVRTYJ5VK036nLsK zgru4bugB1YYgEmeXrNt7VVd7jI3zpiRmYcRf/pqNHvpKzy2ujKpRLyWveB6TvCLdZ9e XuS/ShzjSsQWp3xiXjsu+j4siexbRYOu2O12z+C+vbRyG/5ZN2bV+4NrYSX4+kcfSRnu dfLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:disposition-notification-to :in-reply-to:content-transfer-encoding; bh=bxeMzKxgZ0Eozk4TenAUr9NC7yA+1A+L0XtoFFuD2G4=; b=kTg9uc4AjcxPOWytpmQeMCUrjPREH3MBYCd/bEOc0S26tn9v966XMABeukiXQ5YOga ZQsR6IHCoysowfW4uqtoLvXl2gKTH3CpvgTk1K6jbuRmtWNGZ9UIyYwW3vkzPBZk5f8s wDYNwvuL70MBWcKXt6Ry4nBLPJ84/XMvoewqFvFxGabI2CZFd5SM01/Gjs65f+sNGhZH QIdETQQZUBbegPW7QZkw45mJNzAdqXeOtVmC5JUhbKngtMz9paYPJcbUB5gIiPwaIzXu 6JWgU0UeY4vVSt6j8RaBWHhDoHb9E33Uii2wC0uCpRzCpSjzfjxQFSceTon7vIXCNNXQ 6gDQ== X-Gm-Message-State: AOAM530dvmoLoWMP+n0eNJKzMLKqtgFRAsuHfmFXOMg2TlJdbzRaV5ax Ol1wOiobJOyeuGYPB45t+mu0TeQnW7bp8w== X-Google-Smtp-Source: ABdhPJyd+6PBdGiKSZpvqfz2vSQQxRjjcjzzqJDC58bzcv7goqcFDP+fKsm4tM2e2zVViNzS/dl6uA== X-Received: by 2002:a92:ca45:0:b0:2d1:b7cf:26a9 with SMTP id q5-20020a92ca45000000b002d1b7cf26a9mr7819223ilo.52.1653538047412; Wed, 25 May 2022 21:07:27 -0700 (PDT) Return-Path: Received: from [192.168.1.42] (234.162.207.74.srtnet.com. [74.207.162.234]) by smtp.gmail.com with ESMTPSA id n8-20020a056638120800b0032e79267e0bsm176469jas.0.2022.05.25.21.07.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 21:07:26 -0700 (PDT) Message-ID: <5c4b7ace-37ea-54d6-f881-7f0d074a4cce@gmail.com> Date: Wed, 25 May 2022 23:07:25 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [edk2-devel] including redfish libs results in multiple definitions of symbols To: devel@edk2.groups.io, afish@apple.com, xzavierpower@gmail.com, "Chang, Abner" References: <2BD5DBA6-E682-4983-A17A-1A61400CC383@apple.com> From: "Ethin Probst" In-Reply-To: <2BD5DBA6-E682-4983-A17A-1A61400CC383@apple.com> Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit aren't the Base*Libs there in case you want to override existing implementations or implement custom versions of them? I'm pretty sure that's the logic behind it -- its a hack of sorts to try to get OOP out of a purely procedural language. It works, but I don't think its necessarily ideal. But there really isn't much of an alternative. Then again, I might be wrong, too... On 5/25/22 23:04, Andrew Fish via groups.io wrote: > > >> On May 25, 2022, at 9:23 AM, M.T. > > wrote: >> >> 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: >> > > It looks like BaseSortLib and and SortLib are the same library class so > you should only have one. > > /Volumes/Case/edk2(master)*>*git grep --recurse-submodules SortLib  -- > \*.inf | grep LIBRARY_CLASS > MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:18:  LIBRARY_CLASS >             = SortLib > MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf:18:  LIBRARY_CLASS >             = SortLib|UEFI_APPLICATION UEFI_DRIVER UEFI_DRIVER > DXE_RUNTIME_DRIVER DXE_DRIVER > > > /Volumes/Case/edk2(master)*>*git grep --recurse-submodules BaseSortLib > -- \*.inc > RedfishPkg/RedfishLibs.dsc.inc:16:*BaseSortLib*|MdeModulePkg/Library/*BaseSortLib*/*BaseSortLib*.inf > > OK bingo bingo bingo…. > > The way the edk2 works is you have a library class that maps to the > include file. This is the name in the INF file that resolves linking. > You can have as many instances of the library class as you like. This is > why the DSC files have the | > syntax as you are letting the build pick which instance of the library > to use. You can control this per driver/app if you want. > > It looks to me like BaseSortLib is an alias for SortLib and that is a > bit of hack. > > You could try making sure that BaseSortLib and SortLib point to the same > library instance > > The other option would be to edit RedfishCrtLib.inf and make BaseSortLib > SortLib > > /Volumes/Case/edk2(master)*>*git grep --recurse-submodules BaseSortLib > -- \*.inf > MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:13:  BASE_NAME >             = *BaseSortLib* > MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:14:  MODULE_UNI_FILE >             = *BaseSortLib*.uni > MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf:25:*BaseSortLib*.c > RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.inf:28:*BaseSortLib* > > I’m note sure why this fake BaseSortLib exists. Looks like we would need > to ask Abner? > * > * > commit 6e9233f968735219b2038c5dd23a46be2c021807 > Author: Abner Chang > > Date:   Fri Dec 4 12:30:05 2020 +0800 > >     RedfishPkg/RedfishCrtLib: Redfish C runtime library > > >     Redfish CRT library is currently used by edk2 JsonLib >     (open source jansson project) and edk2 RedfishLib >     (libredfish open source project). Redfish CrtLib library >     provides the necessary C runtime equivalent edk2 functions >     for open source projects. > > >     Signed-off-by: Abner Chang > > > >     Cc: Leif Lindholm > >     Cc: Nickle Wang > >     Cc: Peter O'Hanley > >     Reviewed-by: Nickle Wang > >     Acked-by: Leif Lindholm > >     Reviewed-by: Michael D Kinney > > > * > * > Thanks, > > Andrew Fish > >> /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 > >