You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For shared libraries on Windows all methods in the callable API need to be tagged with __declspec(dllexport), which for the Sdf library is done via the SDF_API macro as defined in pxr/usd/sdf/api.h.
Turns out when this was added to the headers of the Sdf library, a small utility class was missed: SdfSimpleLayerStateDelegate is declared in pxr/usd/sdf/layerStateDelegate.h and is used as the default state delegate for each SdfLayer.
But since the static SdfSimpleLayerStateDelegateRefPtr New(); call is missing the SDF_API tag it cannot be called from a piece of code that dynamically links against the Sdf library. At link time the symbol is missing. Which means this class can't be instantiated from the outside of Sdf.
For context, we have our own implementation of a SdfLayerStateDelegateBase to implement an undo system and when we disconnect our delegate we would like to reset it to the default implementation. Unfortunately we can't call the static New method on SdfSimpleLayerStateDelegate.
Steps to Reproduce
Try to compile the following on windows in a build unit that links dynamically against lib sdf.
It should compile fine, but then get a linker error, since the New function is not exported.
error LNK2019: unresolved external symbol "public: static class pxrInternal_v0_22__pxrReserved__::TfRefPtr<class pxrInternal_v0_22__pxrReserved__::SdfSimpleLayerStateDelegate> __cdecl pxrInternal_v0_22__pxrReserved__::SdfSimpleLayerStateDelegate::New(void)" (?New@SdfSimpleLayerStateDelegate@pxrInternal_v0_22__pxrReserved__@@SA?AV?$TfRefPtr@VSdfSimpleLayerStateDelegate@pxrInternal_v0_22__pxrReserved__@@@2@XZ) referenced in function "void __cdecl `anonymous namespace'::test(void)" (?test@?A0x0c82cd52@@YAXXZ)
Workaround
A way to deal with this issue is to retain the SdfSimpleLayerStateDelegate, which is the default delegate for each SdfLayer via GetStateDelegate() and to restore it when we remove our custom state delegate.
System Information (OS, Hardware)
Windows only. Linux and MacOS are fine, since they handle symbols in dynamic libraries differently.
Package Versions
This was noted with a USD build from 22.08
Build Flags
Do let me know if you have any questions.
Thanks,
Florian
The text was updated successfully, but these errors were encountered:
Description of Issue
For shared libraries on Windows all methods in the callable API need to be tagged with
__declspec(dllexport)
, which for the Sdf library is done via the SDF_API macro as defined inpxr/usd/sdf/api.h
.Turns out when this was added to the headers of the Sdf library, a small utility class was missed:
SdfSimpleLayerStateDelegate
is declared inpxr/usd/sdf/layerStateDelegate.h
and is used as the default state delegate for each SdfLayer.But since the
static SdfSimpleLayerStateDelegateRefPtr New();
call is missing theSDF_API
tag it cannot be called from a piece of code that dynamically links against the Sdf library. At link time the symbol is missing. Which means this class can't be instantiated from the outside of Sdf.For context, we have our own implementation of a
SdfLayerStateDelegateBase
to implement an undo system and when we disconnect our delegate we would like to reset it to the default implementation. Unfortunately we can't call the staticNew
method onSdfSimpleLayerStateDelegate
.Steps to Reproduce
Try to compile the following on windows in a build unit that links dynamically against lib
sdf
.It should compile fine, but then get a linker error, since the
New
function is not exported.Workaround
A way to deal with this issue is to retain the
SdfSimpleLayerStateDelegate
, which is the default delegate for eachSdfLayer
viaGetStateDelegate()
and to restore it when we remove our custom state delegate.System Information (OS, Hardware)
Windows only. Linux and MacOS are fine, since they handle symbols in dynamic libraries differently.
Package Versions
This was noted with a USD build from 22.08
Build Flags
Do let me know if you have any questions.
Thanks,
Florian
The text was updated successfully, but these errors were encountered: