PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
5.99k stars 1.18k forks source link

-DBUILD_SHARED_LIBS=OFF leads to "Cannot determine file format" #1617

Open xwlin-roy opened 3 years ago

xwlin-roy commented 3 years ago

Description of Issue

Steps to Reproduce

  1. I modify the https://github.com/PixarAnimationStudios/USD/blob/7a5f8c4311fed3ef2271d5e4b51025fb0f513730/build_scripts/build_usd.py#L1356 to -DBUILD_SHARED_LIBS=OFF
  2. Then build openusd
  3. when I execute ./sdfdump xxx.usdz, it will report:
    Coding Error: in _OpenLayerAndUnlockRegistry at line 3175 of /home/roy/Desktop/Softwares/USD/pxr/usd/sdf/layer.cpp -- Cannot determine file format for @/home/roy/Desktop/chair_swan.usdz@
    sdfdump: Error - failed to open layer </home/roy/Desktop/chair_swan.usdz>

System Information (OS, Hardware)

Ubuntu 20.04

Package Versions

github latest commit

Build Flags

I modify the https://github.com/PixarAnimationStudios/USD/blob/7a5f8c4311fed3ef2271d5e4b51025fb0f513730/build_scripts/build_usd.py#L1356 to -DBUILD_SHARED_LIBS=OFF

jilliene commented 3 years ago

Filed as internal issue #USD-6894

xwlin-roy commented 2 years ago

Filed as internal issue #USD-6894

any suggestion for this issue?

sunyab commented 2 years ago

Hi @xwlin-roy, thanks for posting. There are some issues with static libraries because USD uses a plugin system to discover and load libraries that supply file format implementations as needed.

I've confirmed sdfdump works for me if I set the environment variable and update the CMakeLists.txt as mentioned above.

MikeCernea commented 2 years ago

Hello, I have a different problem when building USD as static libraries. I get this error when trying to use a binary that was linked to usd static libraries: Coding Error: in CreateAnonymous at line 342 of /home/poly/Libs/src/USD/pxr/usd/sdf/layer.cpp -- Cannot determine file format for anonymous SdfLayer

I am not sure if the issue is with my code(code developed and tested OK with shared usd libs - do I need to adapt it when linking to static usd libs?), the plugin detection or other issue.

Working on Ubuntu 20.04 inside WSL2. The reason for trying out static libraries is that shared ones require to be built and deployed in the same USD install folder on every target machine; we search for a simpler distribution process.

PS: is plugin registration still required when linking to static libraries, i.e. : PlugRegistry& registry = PlugRegistry::GetInstance(); const PlugPluginPtr usd_plugin = registry.GetPluginWithName("usd");

FlorianZ commented 2 years ago

@MikeCernea does manually adding usd to the CMakeLists.txt work around your issue?