Unity-Technologies/usd-unity-sdk

Missing dylibs in macOS builds - Bug in CMake files ?

nicolaspopravka opened this issue · 1 comments

On macOS, I get the DllNotFoundException: UsdCs assembly:<unknown assembly> type:<unknown type> member:(null) error when trying to import USD files using my custom build of the USD package. This is on macOS only. What’s suspicious is what I see in my local package:

pops-mbp:USD Unity SDK nicolas$ ls -l package/com.unity.formats.usd/Runtime/Plugins/x86_64/MacOS/UsdCs.bundle/Contents/Frameworks
total 46336
lrwxr-xr-x  1 nicolas  staff        23 Nov 10 10:45 libAlembic.1.7.dylib -> libAlembic.1.7.10.dylib
lrwxr-xr-x  1 nicolas  staff        20 Nov 10 10:45 libHalf.12.dylib -> libHalf.12.0.0.dylib
lrwxr-xr-x  1 nicolas  staff        23 Nov 10 10:45 libIex-2_2.12.dylib -> libIex-2_2.12.0.0.dylib
lrwxr-xr-x  1 nicolas  staff        27 Nov 10 10:45 libIexMath-2_2.12.dylib -> libIexMath-2_2.12.0.0.dylib
lrwxr-xr-x  1 nicolas  staff        26 Nov 10 10:45 libIlmImf-2_2.22.dylib -> libIlmImf-2_2.22.0.0.dylib
lrwxr-xr-x  1 nicolas  staff        29 Nov 10 10:45 libIlmThread-2_2.12.dylib -> libIlmThread-2_2.12.0.0.dylib
lrwxr-xr-x  1 nicolas  staff        25 Nov 10 10:45 libImath-2_2.12.dylib -> libImath-2_2.12.0.0.dylib
-rw-r--r--  1 nicolas  staff    261248 Nov  9 18:29 libtbb.dylib
-rw-r--r--  1 nicolas  staff  23459184 Nov  9 20:27 libusd_ms.dylib

versus what I see in the USD package installed in my Unity project from the official registry:

pops-mbp:My project nicolas$ ls -l Library/PackageCache/com.unity.formats.usd\@3.0.0-exp.5/Runtime/Plugins/x86_64/MacOS/UsdCs.bundle/Contents/Frameworks
-rw-r--r--@ 1 nicolas  staff   1837544 Oct 19 16:25 libAlembic.1.7.dylib
-rw-r--r--@ 1 nicolas  staff    281560 Oct 19 16:25 libHalf.12.dylib
-rw-r--r--@ 1 nicolas  staff     71296 Oct 19 16:25 libIex-2_2.12.dylib
-rw-r--r--@ 1 nicolas  staff     16472 Oct 19 16:25 libIexMath-2_2.12.dylib
-rw-r--r--@ 1 nicolas  staff   3038864 Oct 19 16:25 libIlmImf-2_2.22.dylib
-rw-r--r--@ 1 nicolas  staff     30064 Oct 19 16:25 libIlmThread-2_2.12.dylib
-rw-r--r--@ 1 nicolas  staff     72832 Oct 19 16:25 libImath-2_2.12.dylib
-rw-r--r--@ 1 nicolas  staff    263016 Oct 19 16:25 libtbb.dylib
-rw-r--r--@ 1 nicolas  staff  24054536 Oct 19 16:25 libusd_ms.dylib

Notice the symlinks to missing USD artifacts in my local build. I tried rebuilding using different versions of CMake as old as 3.13 and all create symlinks. Looking at the CMake files, I see this list and this logic to install these files. However, it looks like on macOS this only install the symlinks and not the actual dylibs. Am I missing something ?

This is not a MacOS only problem. I'm on Ubuntu 22.04, and getting the same error when trying to import a file created by my iPhone RoomKit SDK.

DllNotFoundException: UsdCs assembly:<unknown assembly> type:<unknown type> member:(null)
pxr.UsdCsPINVOKE+SWIGExceptionHelper..cctor () (at ./Library/PackageCache/com.unity.formats.usd@3.0.0-exp.5/Dependencies/USD.NET/generated/UsdCs/UsdCsPINVOKE.cs:164)
Rethrow as TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception.
pxr.UsdCsPINVOKE..cctor () (at ./Library/PackageCache/com.unity.formats.usd@3.0.0-exp.5/Dependencies/USD.NET/generated/UsdCs/UsdCsPINVOKE.cs:184)
Rethrow as TypeInitializationException: The type initializer for 'pxr.UsdCsPINVOKE' threw an exception.
pxr.PlugRegistry.GetInstance () (at ./Library/PackageCache/com.unity.formats.usd@3.0.0-exp.5/Dependencies/USD.NET/generated/pxr/base/plug/PlugRegistry.cs:47)
Unity.Formats.USD.InitUsd.SetupUsdPath (System.String sourceFilePath) (at ./Library/PackageCache/com.unity.formats.usd@3.0.0-exp.5/Common/InitUsd.cs:123)
Unity.Formats.USD.InitUsd.Initialize () (at ./Library/PackageCache/com.unity.formats.usd@3.0.0-exp.5/Common/InitUsd.cs:51)
UnityEngine.Debug:LogException(Exception)
Unity.Formats.USD.InitUsd:Initialize() (at ./Library/PackageCache/com.unity.formats.usd@3.0.0-exp.5/Common/InitUsd.cs:70)
Unity.Formats.USD.ImportHelpers:InitForOpen(String, InitialLoadSet) (at ./Library/PackageCache/com.unity.formats.usd@3.0.0-exp.5/Runtime/Scripts/IO/Scene/ImportHelpers.cs:176)
Unity.Formats.USD.UsdMenu:MenuImportAsGameObjects() (at ./Library/PackageCache/com.unity.formats.usd@3.0.0-exp.5/Editor/Scripts/Behaviors/UsdMenu.cs:172)

and

DllNotFoundException: UsdCs assembly:<unknown assembly> type:<unknown type> member:(null)
pxr.UsdCsPINVOKE+SWIGExceptionHelper..cctor () (at ./Library/PackageCache/com.unity.formats.usd@3.0.0-exp.5/Dependencies/USD.NET/generated/UsdCs/UsdCsPINVOKE.cs:164)
Rethrow as TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception.
pxr.UsdCsPINVOKE..cctor () (at ./Library/PackageCache/com.unity.formats.usd@3.0.0-exp.5/Dependencies/USD.NET/generated/UsdCs/UsdCsPINVOKE.cs:184)
Rethrow as TypeInitializationException: The type initializer for 'pxr.UsdCsPINVOKE' threw an exception.
pxr.UsdStage.Open (System.String filePath, pxr.UsdStage+InitialLoadSet load) (at ./Library/PackageCache/com.unity.formats.usd@3.0.0-exp.5/Dependencies/USD.NET/generated/pxr/usd/usd/UsdStage.cs:194)
Unity.Formats.USD.ImportHelpers.InitForOpen (System.String path, pxr.UsdStage+InitialLoadSet loadSet) (at ./Library/PackageCache/com.unity.formats.usd@3.0.0-exp.5/Runtime/Scripts/IO/Scene/ImportHelpers.cs:178)
Unity.Formats.USD.UsdMenu.MenuImportAsGameObjects () (at ./Library/PackageCache/com.unity.formats.usd@3.0.0-exp.5/Editor/Scripts/Behaviors/UsdMenu.cs:172)