Building a C++ application with USD libraries

Hello,

I’m wondering if anyone could offer some advice regarding how to properly build a C++ application on Windows that utilises the USD libraries, preferably using Visual Studio. I’ve been trying to get something to build with Visual Studio 2019 but I’m getting nothing but errors, so I’m assuming there’s something I’ve missed (or perhaps I’m taking the wrong approach entirely), but I’m struggling to figure it out. I’m using the OpenUSD 24.05 prebuilt binaries available from Nvidia’s website, in case that’s of any note.

My project is set up as follows:

  • Empty C++ project in VS
  • Language standard set to C++20
  • Additional Include Directories contains the following paths:
    C:\OpenUSD\OpenUSD-24.05_prebuilt\include
    C:\OpenUSD\OpenUSD-24.05_prebuilt\include\boost-1_78
    C:\OpenUSD\OpenUSD-24.05_prebuilt\python\include
  • Additional Library Directories contains the following paths:
    C:\OpenUSD\OpenUSD-24.05_prebuilt\lib
  • Additional Dependencies contains all of the .lib files within the lib directory (I realise it is probably unnecessary to have every single one, I was just trying whatever I could think of to get something to work).

Then my source code is simply

#include <pxr/usd/usd/stage.h>

int main(int argc, char** argv)
{
    return 0;
}

Attempting to build this results in a plethora of errors including (but not limited to)

If anyone has any advice or suggestions for how I should get started with building an app with USD’s C++ libraries, that would be greatly appreciated.

Thanks,
Callum

I think the closest thing that is currently available as a boilerplate application is GitHub - meshula/tinyusd: A really small getting-started project for USD based projects , but it still builds OpenUSD from scratch rather than bringing it in via package management, and is set up for Xcode, not Visual Studio.

Some of the other resources at GitHub - matiascodesal/awesome-openusd: A curated list of awesome Universal Scene Description (OpenUSD) resources and projects might also help, and GitHub - NVIDIA-Omniverse/kit-app-template: Omniverse Kit App Template is a superset of what you want-- you can use it to developer USD applications… but the community likely does need something more lightweight “hello world” boilerplate C++ app that also does not require building OpenUSD from scratch.

Buildsystems and package management are a topic that we’ll be discussing in the AOUSD Technical Advisory Committee-- for now, maybe uploading your VS project source files as a GitHub issue might be the way to go, so that someone else can try to reproduce your workflow.

1 Like

Hi @csmith ,
Seeing the errors you got I am wondering if your main file is not seen as a C file (main.c) instead of a C++ file.
I would recommend using cmake to generate your project using USD, there is also an example using the nvidia libs in GitHub - cpichard/usdtweak: Universal Scene Description standalone editor , (see Using NVidia’s USD build) although it dates a little bit, it might be helpful. The CMakeLists.txt in this project file can be used as a template.

also see Issue building simple app using usd C++ librairies