How do I manually link OpenUsd plugins into my project?

Issue: Only the first plugin directory gets registered in USD’s PlugRegistry

I’m trying to register multiple USD plugins using pxr::PlugRegistry::RegisterPlugins(). However, only the first directory string it reads gets registered, and the others are ignored. I’m doing this manually, since I’m an intern and I’m trying to export objects from a simulation model. I don’t have permissions to use system variables so I have to manually add the paths via this function.

Code snippet:

cpp

pxr::PlugRegistry::GetInstance().RegisterPlugins("path/to/plugin1");
pxr::PlugRegistry::GetInstance().RegisterPlugins("path/to/plugin2");
pxr::PlugRegistry::GetInstance().RegisterPlugins("path/to/plugin3");

Only plugin1 gets registered, while plugin2 and plugin3 are missing when I try to retrieve them with GetPluginWithName(). It does matter what order I put the plugins in since only the first string (or even the first string in a string vector) gets registered.

What I found:

It seems that USD caches plugin discovery on the first call to RegisterPlugins(), so calling it multiple times with different paths doesn’t work. I tried looping.

Can anyone explain if I’m doing anything wrong? I’m also open to other solutions to link the plugins.

@mati-nvidia

Please provide more context. Are you running this within a Kit extension, a non-Kit project, or what sort of environment is this?

Thank you for your response. This is a non-Kit project. I’m working on integrating USD into a custom C++ (simulation) application, and I’m trying to make a USD scene with a basic object so I can provide a prototype of linking it uni-directional to Nvidia Omniverse, possible bi-directional at some point.

Let me know if you need anymore information.

A non-kit project? This forum is for Omniverse and Kit. If you are working on a non-kit project, we cannot really provide support for it. We have designed kit to integrate well with USD. If you are choosing to go outside of kit, it will be difficult for us to support your integration. We have no way of knowing if your custom usd project will work with Omniverse, if you work outside of kit.