Link fails against usd_tf in simple test program (Ubuntu 22.04)

I’m trying to compile with clang on Linux and link against a pre-built OpenUSD distribution, which defaults to g++. My simple test program fails at link time, because it can’t find:

pxrInternal_v0_24__pxrReserved__::TfStringPrintf(char const*, ...)

And sure enough, the symbol actually in libusd_tf.so is:

pxrInternal_v0_24__pxrReserved__::TfStringPrintf[abi:cxx11](char const*, ...)

I have two options:

  1. Change the options to my compiler so that it actually looks for the symbol that exists. I haven’t been able to do this so far.
  2. Rebuild OpenUSD with clang. What’s the easiest way to do this?

Any tips would be appreciated.

Hey Arun, perhaps _GLIBCXX_USE_CXX11_ABI is what you are looking for?

Regarding 2: would set CXX to clang++ and CC to clang and then run the build script as described in the README.

Thanks. I have tried the following:

  • Set clang copts to -stdlib=libstdc++11. Can’t find that library.
  • Set clang copts to -stdlib=libstdc++. Can’t find the “iostream” header!
  • Set _GLIBCXX_USE_CXX11_ABI=1 in my program, before the first Usd header. Does nothing.
  • Rebuilt OpenUSD with --use-cxx11-abi=0. This links, but produces garbage in stdout.
  • Setting CXX alone to clang++ doesn’t seem to work at all (it appears that it doesn’t grab anything else from the llvm distro).