martin-olivier / dylib

C++ cross-platform wrapper around dynamic loading of shared libraries (dll, so, dylib)
https://conan.io/center/recipes/dylib
MIT License
293 stars 44 forks source link

feat: print missing dependencies of the dll #71

Open dayfixer opened 1 year ago

dayfixer commented 1 year ago

Description

Windows:when defined DYLIB_PRINT_MISSING before include dylib.hpp, the missing dependecies of the dlll will be printed

test sample:

TEST(open, open_missing_dependecy){
    try {
        dylib lib("./", "opencv_img_hash440");
    }
    catch (const dylib::load_error & error) {
        std::cout << error.what();
        EXPECT_EQ(true, true);
    }
}
1: [==========] Running 1 test from 1 test suite.
1: [----------] Global test environment set-up.
1: [----------] 1 test from open
1: [ RUN      ] open.open_missing_dependecy
1: The specified module could not be found.
1: 
1:   Loaded fail:  (file missing or its dependencies were not found) 
1:     1: opencv_world440.dll
1: [       OK ] open.open_missing_dependecy (3 ms)
1: [----------] 1 test from open (3 ms total)
codecov[bot] commented 12 months ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (92ab0f3) 100.00% compared to head (9dd9c30) 100.00%. Report is 1 commits behind head on main.

:exclamation: Current head 9dd9c30 differs from pull request most recent head d16798b. Consider uploading reports for the commit d16798b to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #71 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 1 1 Lines 58 60 +2 Branches 3 3 ========================================= + Hits 58 60 +2 ``` | [Files](https://app.codecov.io/gh/martin-olivier/dylib/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Martin+Olivier) | Coverage Δ | | |---|---|---| | [include/dylib.hpp](https://app.codecov.io/gh/martin-olivier/dylib/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Martin+Olivier#diff-aW5jbHVkZS9keWxpYi5ocHA=) | `100.00% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

martin-olivier commented 11 months ago

Hello @dayfixer,

Thanks for your PR. I think it could be a good Idea to integrate that by default when an error occurs, without specifying DYLIB_PRINT_MISSING. Also, maybe we could add a depends_on() -> std::vector<std::string> function on windows to be able to collect this data