PixarAnimationStudios / OpenUSD

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

Run-time error trying to load alembic files #3101

Open drperpen opened 5 months ago

drperpen commented 5 months ago

Description of Issue

Run-time error trying lo load alembic files. I am guessing it has to do with the plugin folder structure or plugin path. I have all the .dll in the build folder and also the 'usd' lib folder along with the .exe: /build --usd_test.exe --*.dll --/usd ----/ar ------/resources --------/plugInfo.json ----/glf etc...

Steps to Reproduce

cmake_minimum_required(VERSION 3.20)
project(usd_test)

set(CMAKE_CXX_STANDARD 20)

set(pxr_DIR S:/dev/libs/OpenUSD)

find_package(pxr CONFIG REQUIRED HINTS pxr_DIR)
link_directories(${pxr_DIR}/lib)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

add_compile_definitions(NOMINMAX)

add_executable(usd_test src/main.cpp)

target_link_libraries(usd_test usd)
#include <iostream>
#include "pxr/usd/usd/stage.h"
#include "pxr/usd/usd/prim.h"

int main() {
    std::cout << "Hello, World!" << std::endl;
    std::string filePath = "C:/mesh.abc";
    pxr::UsdStageRefPtr stage = pxr::UsdStage::Open(filePath);

    return 0;
}
Hello, World!
Coding Error: in _Load at line 261 of S:\dev\libs\OpenUSD-24.03\OpenUSD-24.03\pxr\base\plug\plugin.cpp -- Failed to load plugin 'usdAbc': The specified module could not be found.
 in 's:/dev/git/usd_test/build/usdAbc.dll'
Coding Error: in _Load at line 261 of S:\dev\libs\OpenUSD-24.03\OpenUSD-24.03\pxr\base\plug\plugin.cpp -- Failed to load plugin 'usdAbc': The specified module could not be found.
 in 's:/dev/git/usd_test/build/usdAbc.dll'

System Information (OS, Hardware)

Windows 10

Package Versions

24.05

Build Flags

build_usd.py s:\dev\libs\OpenUSD --no-python --alembic --hdf5 --openimageio --opencolorio --embree
jesschimein commented 5 months ago

Filed as internal issue #USD-9714

meshula commented 5 months ago

Hi @drperpen

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 where to load the plugins from.

drperpen commented 5 months ago

Thanks for your reply @meshula I get the same output as in my first message when set TFDEBUG=PLUG_INFO_SEARCH and the run my test program. Do I have to setup something in Cmake and rebuild as well for this to work?

A test to give more context:

int main() {
    _putenv("TFDEBUG=PLUG_INFO_SEARCH");

    std::string dsoError;
    std::string _path = "S:/dev/libs/OpenUSD/plugin/usd/usdAbc.dll";
    auto _handle = pxr::TfDlopen(_path.c_str(), ARCH_LIBRARY_NOW, &dsoError);
    if (!_handle) {
        std::cout << "No plugin loaded" << std::endl;
        std::cout << dsoError << std::endl;
    }
    return 0;
}

//
No plugin loaded
The specified module could not be found.
meshula commented 5 months ago

To be sure, could I ask you to set these variables in cmd.exe, and run your program from that same session? I haven't personally tried setting the TFDEBUG variable with _putenv so I don't know if it works as you are expecting.

set PXR_PLUGINPATH_NAME=S:/dev/libs/OpenUSD/plugin/usd
set TFDEBUG=PLUG_INFO_SEARCH
yourMain.exe
drperpen commented 5 months ago

@meshula here's the output of that:

s:\dev\git\usd_test\build\Release>set PXR_PLUGINPATH_NAME=S:/dev/libs/OpenUSD/plugin/usd

s:\dev\git\usd_test\build\Release>set TFDEBUG=PLUG_INFO_SEARCH

s:\dev\git\usd_test\build\Release>usd_test.exe
Hello, World!
Coding Error: in _Load at line 261 of S:\dev\libs\OpenUSD-24.03\OpenUSD-24.03\pxr\base\plug\plugin.cpp -- Failed to load plugin 'usdAbc': The specified module could not be found.
 in 's:/dev/libs/OpenUSD/plugin/usd/usdAbc.dll'
Coding Error: in _Load at line 261 of S:\dev\libs\OpenUSD-24.03\OpenUSD-24.03\pxr\base\plug\plugin.cpp -- Failed to load plugin 'usdAbc': The specified module could not be found.
 in 's:/dev/libs/OpenUSD/plugin/usd/usdAbc.dll'
Coding Error: in _OpenLayerAndUnlockRegistry at line 3320 of S:\dev\libs\OpenUSD-24.03\OpenUSD-24.03\pxr\usd\sdf\layer.cpp -- Cannot determine file format for @//driveD/mesh.abc:SDF_FORMAT_ARGS:target=usd@
Runtime Error: in Open at line 1059 of S:\dev\libs\OpenUSD-24.03\OpenUSD-24.03\pxr\usd\usd\stage.cpp -- Failed to open layer @//driveD/mesh.abc@
usd:
asluk commented 5 months ago

the env var is TF_DEBUG -- here's what I do in powershell for things like this

$env:TF_DEBUG = "PLUG*"

and you should see terminal output that looks like

Plug will search for plug infos under 'C:\Users\aluk\AppData\Local\ov\pkg\usdview-0.24.5\lib\' Will check plugin info paths: c:/Users/aluk/AppData/Local/ov/pkg/usdview-0.24.5/lib/usd c:/Users/aluk/AppData/Local/ov/pkg/usdview-0.24.5/plugin/usd Will read plugin info c:/Users/aluk/AppData/Local/ov/pkg/usdview-0.24.5/lib/usd/plugInfo.json Did read plugin info c:/Users/aluk/AppData/Local/ov/pkg/usdview-0.24.5/lib/usd/plugInfo.json Globbing plugin info path c:/Users/aluk/AppData/Local/ov/pkg/usdview-0.24.5/lib/usd/*/resources/

drperpen commented 5 months ago

Thanks @asluk , that worked. It seems it finds the plugin and can register, but then The specified module could not be found:

PS S:\dev\git\usd_test\build\Release> .\volcap_tracker.exe
Hello, World!
Plug will search for plug infos under 'S:\dev\git\usd_test\build\Release\'
Will check plugin info paths:
    s:/dev/git/usd_test/build/Release/usd
    s:/dev/git/usd_test/build/plugin/usd
Will read plugin info s:/dev/git/usd_test/build/Release/usd/plugInfo.json
 Did read plugin info s:/dev/git/usd_test/build/Release/usd/plugInfo.json
Globbing plugin info path s:/dev/git/usd_test/build/Release/usd/*/resources/
Will read plugin info s:/dev/git/usd_test/build/Release/usd/usd/resources/plugInfo.json
Will read plugin info s:/dev/git/usd_test/build/Release/usd/sdf/resources/plugInfo.json
Will read plugin info s:/dev/git/usd_test/build/Release/usd/ar/resources/plugInfo.json
Will read plugin info s:/dev/git/usd_test/build/Release/usd/usdGeom/resources/plugInfo.json
 Did read plugin info s:/dev/git/usd_test/build/Release/usd/ar/resources/plugInfo.json
 Did read plugin info s:/dev/git/usd_test/build/Release/usd/sdf/resources/plugInfo.json
Registering shared library plugin 'ar' at 's:/dev/git/usd_test/build/Release/usd_ar.dll'.

 Did read plugin info s:/dev/git/usd_test/build/Release/usd/usd/resources/plugInfo.json
Registering shared library plugin 'sdf' at 's:/dev/git/usd_test/build/Release/usd_sdf.dll'.

Registering shared library plugin 'usd' at 's:/dev/git/usd_test/build/Release/usd_usd.dll'.

 Did read plugin info s:/dev/git/usd_test/build/Release/usd/usdGeom/resources/plugInfo.json
Registering shared library plugin 'usdGeom' at 's:/dev/git/usd_test/build/Release/usd_usdGeom.dll'.

Will read plugin info s:/dev/git/usd_test/build/plugin/usd/plugInfo.json
 Did read plugin info s:/dev/git/usd_test/build/plugin/usd/plugInfo.json
Globbing plugin info path s:/dev/git/usd_test/build/plugin/usd/*/resources/
Will read plugin info s:/dev/git/usd_test/build/plugin/usd/usdAbc/resources/plugInfo.json
 Did read plugin info s:/dev/git/usd_test/build/plugin/usd/usdAbc/resources/plugInfo.json
Registering shared library plugin 'usdAbc' at 's:/dev/git/usd_test/build/plugin/usd/usdAbc.dll'.

 Did check plugin info paths in 0.002753 seconds
Loading plugin 'usdAbc'.
Coding Error: in _Load at line 261 of S:\dev\libs\OpenUSD-24.03\OpenUSD-24.03\pxr\base\plug\plugin.cpp -- Failed to load plugin 'usdAbc'
: The specified module could not be found.
 in 's:/dev/git/usd_test/build/plugin/usd/usdAbc.dll'
Loading plugin 'usdAbc'.
Coding Error: in _Load at line 261 of S:\dev\libs\OpenUSD-24.03\OpenUSD-24.03\pxr\base\plug\plugin.cpp -- Failed to load plugin 'usdAbc'
: The specified module could not be found.
 in 's:/dev/git/usd_test/build/plugin/usd/usdAbc.dll'
Coding Error: in _OpenLayerAndUnlockRegistry at line 3320 of S:\dev\libs\OpenUSD-24.03\OpenUSD-24.03\pxr\usd\sdf\layer.cpp -- Cannot det
ermine file format for @//driveD/mesh.abc:SDF_FORMAT_ARGS:target=usd@
Runtime Error: in Open at line 1059 of S:\dev\libs\OpenUSD-24.03\OpenUSD-24.03\pxr\usd\usd\stage.cpp -- Failed to open layer @//driveD/mesh.abc:SDF_FORMAT_ARGS:target=usd@
usd:
drperpen commented 5 months ago

@asluk @meshula More context. From the bin folder I can run ie sdfdump.exe without issues, but if I try usdcat.exe to convert:

s:\dev\libs\OpenUSD\bin>usdcat.exe head.abc --out test.usd
Failed to open "head_stab.1001.abc" - Failed to load plugin 'usdAbc': The specified module could not be found.
 in 's:/dev/libs/OpenUSD/plugin/usd/usdAbc.dll'
Failed to load plugin 'usdAbc': The specified module could not be found.
 in 's:/dev/libs/OpenUSD/plugin/usd/usdAbc.dll'
Cannot determine file format for @head.abc@

The TF_DEBUG output:

Registering shared library plugin 'usdAbc' at 's:/dev/libs/OpenUSD/plugin/usd/usdAbc.dll'.

 Did check plugin info paths in 0.010022 seconds
Loading plugin 'usdAbc'.
Coding Error: in _Load at line 261 of S:\dev\libs\OpenUSD-24.03\OpenUSD-24.03\pxr\base\plug\plugin.cpp -- Failed to load plugin 'usdAbc': The specified module could not be found.
 in 's:/dev/libs/OpenUSD/plugin/usd/usdAbc.dll'
Loading plugin 'usdAbc'.
Coding Error: in _Load at line 261 of S:\dev\libs\OpenUSD-24.03\OpenUSD-24.03\pxr\base\plug\plugin.cpp -- Failed to load plugin 'usdAbc': The specified module could not be found.
 in 's:/dev/libs/OpenUSD/plugin/usd/usdAbc.dll'
error: unknown output file extension.
asluk commented 5 months ago

I think in addition to the env vars in https://openusd.org/release/tut_usd_tutorials.html#environment-setup you also need to add USD_INSTALL_ROOT/plugin to your PATH, but I forget whether PXR_PLUGINPATH_NAME is already supposed to cover that.

drperpen commented 5 months ago

Thanks @asluk What ended up working for me after the setting of PATH for bin, lib and plugin: manually copying Imath-3_1.dll (found in /bin) to my executable root folder.

meshula commented 5 months ago

@drperpen Does that mean that even though Imath-3_1.dll was in bin, and in your path, it was not resolved? And so copying it to your executable root folder solved the problem?

drperpen commented 4 months ago

@meshula Yes, that was it.

dgovil commented 1 week ago

@drperpen Curious if you are able to reproduce the issue with the imath dll going into the wrong spot with USD 24.11? I don't see a cause for that in the build code.