# Setting up Debugging USD code in CLion on macOS

**URL:** <https://forum.aousd.org/t/setting-up-debugging-usd-code-in-clion-on-macos/1542>\
**Category:** Build and Deployment\
**Created:** [May 22, 2024, 4:29pm UTC](https://forum.aousd.org/t/setting-up-debugging-usd-code-in-clion-on-macos/1542 "2024-05-22T16:29:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andybeers](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/andybeers/32/479_2.png) [@andybeers](https://forum.aousd.org/u/andybeers)\
**Post date:** [May 22, 2024, 4:29pm UTC](https://forum.aousd.org/t/setting-up-debugging-usd-code-in-clion-on-macos/1542/1 "2024-05-22T16:29:19Z")

</div>

I’m trying to set up local debugging of USD and I’m able to get the project and many targets to build however at runtime my plugInfo.json’s are not in the right place.

When building with the `build_usd.py` script locally I get the ‘normal’ output directory structure with a lib folder containing all the libraries and within that all the USD project folders with a resources folder and a `plugInfo.json` inside. However when loading the CMake project from within CLion, the lib folder is never created, and the resources folders are not either. The plugInfo files exist within the `cmake-build-debug` folder however their relative paths are wrong.

My current setup is described [here](https://github.com/beersandrew/usd-test-assets/tree/main/debug) .

It’s not necessary for me to use CLion to do this, so if there are easier setup steps someone has to step through USD code, I would appreciate hearing how you’re set up.

Andy

---

<div class="post-metadata">

**Author:** ![nporcino](https://avatars.discourse-cdn.com/v4/letter/n/3d9bf3/32.png) [@nporcino](https://forum.aousd.org/u/nporcino)\
**Post date:** [May 29, 2024, 2:07am UTC](https://forum.aousd.org/t/setting-up-debugging-usd-code-in-clion-on-macos/1542/2 "2024-05-29T02:07:16Z")

</div>

To help debug this issue, be sure to set this envvar:

TFDEBUG=PLUG\_INFO\_SEARCH

This will output helpful diagnostics that will probably highlight the problem immediately. (You’ll be able to see if the path you need is there or not.)

PXR\_PLUGINPATH\_NAME=whatever

will be the next envvar for you to set, because that’s how you can tell OpenUSD, from within your IDE, where to load the plugins from.

Getting specifically a debug build to work might be tricky with custom (or target-named) build folders. So maybe start with a RelWithDebInfo target (hopefully it doesn’t append a suffix? I’m not seeing a suffix in my build folders, but I’m not using CLion). I think it’s helpful to avoid having to solve all of the problems at once 🙂

---

<div class="post-metadata">

**Author:** ![kohakukun](https://avatars.discourse-cdn.com/v4/letter/k/a587f6/32.png) [@kohakukun](https://forum.aousd.org/u/kohakukun)\
**Post date:** [June 4, 2024, 10:55am UTC](https://forum.aousd.org/t/setting-up-debugging-usd-code-in-clion-on-macos/1542/3 "2024-06-04T10:55:06Z")

</div>

I’m using CLion too. What I usually do is that I run the build\_usd.py with the verbose option -v to get the cmake options and use them in my IDE.

One other thing that you might be missing is the install step. I think that is the one that correctly puts the plugin resources corresponding with the library structure

---

<div class="post-metadata">

**Author:** ![andybeers](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/andybeers/32/479_2.png) [@andybeers](https://forum.aousd.org/u/andybeers)\
**Post date:** [June 4, 2024, 7:25pm UTC](https://forum.aousd.org/t/setting-up-debugging-usd-code-in-clion-on-macos/1542/4 "2024-06-04T19:25:41Z")

</div>

Thanks @kohakukun & @nporcino , this helped me get closer i think. It seems now my libs are building in two locations. this causes issues [here](https://github.com/PixarAnimationStudios/OpenUSD/blob/release/pxr/base/tf/debug.cpp#L137) since i end up registering Tf\_Debug symbols multiple times. I can hack around this a little by commenting out some areas of code but it eventually will die because having two different versions of the libraries in the path eventually just doesn’t work.

In my case the paths that libraries get built to are:

- \<build\_dir\>/pxr/\*\*/xx.dylib
- \<build\_dir\>/lib/xx.dylib

so initially I get logs of something like:

```auto
TfRegistryManager: Library <build_dir>/pxr/usd/usd/libusd_usd.dylib
TfRegistryManager: running 1 functions for TfDebug
pxrInternal_v0_24 __pxrReserved__ ::Tf_DebugSymbolRegistry::_Register: USD_AUTO_APPLY_API_SCHEMAS

```

then later after i’m already inside of `usdcat` something similar, this time from the different location

```auto
Loading plugin 'usd'.
TfDlopen: [opening] '<build_dir>/lib/libusd_usd.dylib' (flag=2)...
TfRegistryManager: Library <build_dir>/lib/libusd_usd.dylib
TfRegistryManager: running 1 functions for TfDebug
pxrInternal_v0_24 __pxrReserved__ ::Tf_DebugSymbolRegistry::_Register: USD_AUTO_APPLY_API_SCHEMAS

```

This gets me closer to doing what I really want to do, which is to step through `usdcat` but it seems with these duplicated libraries, when i try to step into where the usdc file format code actually does it’s work, it breaks and doesn’t know where to go.

[here](https://github.com/beersandrew/usd-test-assets/tree/main/debug#current-cmake-options-in-clion) are my current settings for my debug build in CLion, maybe something here is obviously wrong.

It seems I’m set up completely wrong, or that I’m fighting mac based things that make it harder than it needs to be? Maybe rather than digging into my current problems, would anyone be willing to post some ‘hello world’ example of how they are stepping through code? Would the generic advice here be more of :

1. Getting off of macOS
2. Learning more about CMake
3. Learning more about CLion
4. Getting off of CLion and learning gdb / lldb
5. Something else?

Apologies as I know these types of issues are pretty individual, but I’ve been stuck on this for far too long and if there is some ‘standard’ way to do this, that would be very helpful. (totally happy to switch OS / tools / anything)

---

<div class="post-metadata">

**Author:** ![nporcino](https://avatars.discourse-cdn.com/v4/letter/n/3d9bf3/32.png) [@nporcino](https://forum.aousd.org/u/nporcino)\
**Post date:** [June 4, 2024, 8:44pm UTC](https://forum.aousd.org/t/setting-up-debugging-usd-code-in-clion-on-macos/1542/5 "2024-06-04T20:44:52Z")

</div>

This is the build location, you shouldn’t be referencing it at all. Think of it as a staging area.

\<build\_dir\>/pxr/usd/usd/libusd\_usd.dylib

This is the install location: \<build\_dir\>/lib/libusd\_usd.dylib

That’s the one that should be in your paths. When you build in your IDE (it doesn’t matter if it is CLion or Xcode or whatever), you need to build the install target to actually get everything staged to the right place.

Then, when you run, you have to coerce the IDE to run usdcat from the install location, not from the build location. You may have to do more work to tell clion/lldb where the symbol database is, but I’m not sure, as i don’t use CLion (I use the command line or xcode depending on the type of debugging I am doing.)

---

<div class="post-metadata">

**Author:** ![andybeers](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/andybeers/32/479_2.png) [@andybeers](https://forum.aousd.org/u/andybeers)\
**Post date:** [June 5, 2024, 4:58pm UTC](https://forum.aousd.org/t/setting-up-debugging-usd-code-in-clion-on-macos/1542/6 "2024-06-05T16:58:17Z")

</div>

> you have to coerce the IDE to run usdcat from the install location, not from the build location.

Thanks @nporcino, this was a huge part of this. and now it’s working! Appreciate the help so much 🙂

Updated / Documented my steps for getting this to work [here](https://github.com/beersandrew/usd-test-assets/tree/main/debug). If anyone finds this in the future and it doesn’t work for them or if anyone cares to try my steps, I’d like to keep them up to date.
