# usdSchemaExamples confusion

**URL:** <https://forum.aousd.org/t/usdschemaexamples-confusion/1294>\
**Category:** Build and Deployment\
**Created:** [March 5, 2024, 2:09pm UTC](https://forum.aousd.org/t/usdschemaexamples-confusion/1294 "2024-03-05T14:09:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![craig](https://avatars.discourse-cdn.com/v4/letter/c/ed8c4c/32.png) [@craig](https://forum.aousd.org/u/craig)\
**Post date:** [March 5, 2024, 2:09pm UTC](https://forum.aousd.org/t/usdschemaexamples-confusion/1294/1 "2024-03-05T14:09:54Z")

</div>

I’m new to USD and trying to understand the intended use of parts of  
usdSchemaExamples. I can’t find an explanation in the docs.

Firstly, why is schema.usda installed under  
share/usd/examples/plugin/usdSchemaExamples/resources/usdSchemaExamples/  
when there’s already resources/generatedSchema.usda, which I thought  
was sufficient? Is schema.usda still required for a non-codeless  
schema?

Second, are there circumstances under which usdSchemaExamples.so is  
dlopened?

Here’s where the confusion arises…

I can see the Python extension module \_usdSchemaExamples.so links  
against usdSchemaExamples.so (found relative to $ORIGIN).

```auto
  python3 build_scripts/build_usd.py -v ~/dev/usd_build_default
  cd ~/dev/usd_build_default
  readelf -d ./lib/python/pxr/UsdSchemaExamples/_usdSchemaExamples.so | grep -e 'NEEDED.*Schema' -e RUNPATH
  0x0000000000000001 (NEEDED) Shared library: [usdSchemaExamples.so]
  0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/../../../../share/usd/examples/plugin:$ORIGIN/../../..:/home/craig/dev/usd_build_default/lib]

```

It’s been called usdSchemaExamples.so and placed under a plugin/  
subdir, which suggests it’s a plug-in that’s dlopened by a core USD  
library, rather than being called libusdSchemaExamples.so and living  
under an lib/ subdir as I’d expect for a shared library that’s  
explicitly linked to.

If I set PXR\_PLUGINPATH\_NAME to the resources dir,  
TF\_DEBUG=“PLUG\_\* TF\_DLOPEN”, then usdview a test.usda containing an  
Xform prim with the ParamsAPI schema applied, only the  
generatedSchema.usda and plugInfo.json are loaded.  
usdSchemaExamples.so is never dlopened, despite it being  
“registered” as a “plugin”. The TF\_DEBUG output, missing TfDlopen:

```auto
  Will read plugin info /home/craig/dev/usd_build_default/share/usd/examples/plugin/usdSchemaExamples/resources/plugInfo.json
   Did read plugin info /home/craig/dev/usd_build_default/share/usd/examples/plugin/usdSchemaExamples/resources/plugInfo.json
  Registering shared library plugin 'usdSchemaExamples' at '/home/craig/dev/usd_build_default/share/usd/examples/plugin/usdSchemaExamples.so'.

```

According to strace, only the files for a “codeless schema” are opened:

```auto
  strace -f -e trace=openat usdview ./test.usda 2>&1 | grep examples
  [pid 20707] openat(AT_FDCWD, "/home/craig/dev/usd_build_default/share/usd/examples/plugin/usdSchemaExamples/resources/plugInfo.json", O_RDONLY) = 3
  [pid 20707] openat(AT_FDCWD, "/home/craig/dev/usd_build_default/share/usd/examples/plugin/usdSchemaExamples/resources/generatedSchema.usda", O_RDONLY) = 22

```

Is usdSchemaExamples.so supposed to be dlopened at some point? Or  
it’s only required by the Python module (\_usdSchemaExamples.so) and  
the Unix “lib” naming convention has been disregarded there for some  
reason?

Adding to the confusion, there are other DSOs which _are_ dlopened:

```auto
Loading plugin 'hgiGL'.
TfDlopen: [opening] '/home/craig/dev/usd_build_default/lib/libusd_hgiGL.so' (flag=2)...
TfDlopen: [opened] '/home/craig/dev/usd_build_default/lib/libusd_hgiGL.so' (handle=0x55f776173d60)
Loading plugin 'hdStorm'.
TfDlopen: [opening] '/home/craig/dev/usd_build_default/plugin/usd/hdStorm.so' (flag=2)...
TfDlopen: [opened] '/home/craig/dev/usd_build_default/plugin/usd/hdStorm.so' (handle=0x55f7773d46c0)

```

Despite being a “plugin” libusd\_hgiGL.so is also required by other libs:

```auto
  readelf -d ./lib/libusd_hdSt.so | grep 'NEEDED.*GL'
  0x0000000000000001 (NEEDED) Shared library: [libusd_hgiGL.so]

```

So it seems the choice of lib/ vs plugin/ directory names and “lib” as  
a soname prefix has no meaning anymore, and there’s no separation  
between required/needed shared libraries and dlopened plug-ins in USD?

Thanks
