Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logging when plugin loading fails #8

Open
DrMechanica opened this issue Jun 24, 2020 · 6 comments
Open

Improve logging when plugin loading fails #8

DrMechanica opened this issue Jun 24, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@DrMechanica
Copy link

Hey there, trying to build just a basic command line app that utilizes the SDK. Builds okay, but I get the following errors when calling wooting_analog_initialize():

ERROR wooting_analog_sdk::cplugin] dlsym(0x100059d90, _name): symbol not found

ERROR wooting_analog_sdk::sdk] Load Plugin failed: Error(Msg("Plugin isn\'t a valid plugin, name function not found"), State { next_error: None, backtrace: InternalBacktrace { backtrace: None } })

As far as I can tell, I've set everything up correctly according to the instructions in the read me, with libwooting_analog_sdk.dylib in /usr/local/lib and libwooting_analog_plugin.dylib in /Library/WootingAnalogPlugins/wooting-analog-plugin.

Is there something I'm missing here?

Thanks,
-M.

@PastaJ36
Copy link
Member

PastaJ36 commented Jun 24, 2020

It could be because of C++ name mangling. We expose a C interface, but C++ handles naming a little different than C. Did you define the library functions with Extern "C"? Here's an example.

Check Simon's answer below

@simon-wh
Copy link
Member

simon-wh commented Jun 24, 2020

Hmmm, this is an unusual issue.

  • I assume you downloaded the SDK from Github, v0.4.0?
  • Could you give me the entire log output from running it when running it with the environment variable RUST_LOG set to debug? i.e. RUST_LOG=debug command_for_running_your_app
  • Also, what MacOS version are you running?

The locations you placed the SDK components look about right.
Also, @PastaJ36 this looks to be an issue internal to the SDK, where it's loading the plugins, not the dev-facing C ABI

@simon-wh simon-wh added the bug Something isn't working label Jun 24, 2020
@DrMechanica
Copy link
Author

Hey Simon and Pasta,
Thanks for getting back to me so quickly! Simon, to your questions:

• Yes, running v0.4.0
• Log is as follows:

[2020-06-25T20:29:53Z WARN  wooting_analog_sdk::sdk] Failed to load any plugins from "/Library/WootingAnalogPlugins"!
[2020-06-25T20:29:53Z INFO  wooting_analog_sdk::sdk] Attempting to load plugin: "/Library/WootingAnalogPlugins/wooting-analog-plugin/libwooting_analog_plugin.dylib"
[2020-06-25T20:29:53Z INFO  wooting_analog_sdk::sdk] Plugin got plugin-dev sem version: 0.4.0. SDK: 0.4.0
[2020-06-25T20:29:53Z INFO  wooting_analog_sdk::sdk] Plugin and SDK are compatible!
[2020-06-25T20:29:53Z DEBUG wooting_analog_sdk::sdk] We got it and we're trying
[2020-06-25T20:29:53Z INFO  wooting_analog_sdk::sdk] Loaded plugin: "Wooting Official Plugin"
[2020-06-25T20:29:53Z INFO  wooting_analog_sdk::sdk] Loaded 1 plugins from "/Library/WootingAnalogPlugins/wooting-analog-plugin"
[2020-06-25T20:29:53Z INFO  wooting_analog_sdk::sdk] Attempting to load plugin: "/Library/WootingAnalogPlugins/wrapper/libwooting_analog_wrapper.dylib"
[2020-06-25T20:29:53Z INFO  wooting_analog_sdk::sdk] Unable to determine the Plugin's SemVer!
[2020-06-25T20:29:53Z WARN  wooting_analog_sdk::sdk] Find constructor error: dlsym(0x115be06f0, _plugin_create): symbol not found
[2020-06-25T20:29:53Z WARN  wooting_analog_sdk::sdk] Didn't find _plugin_create, assuming it's a c plugin
[2020-06-25T20:29:53Z ERROR wooting_analog_sdk::cplugin] dlsym(0x115be06f0, _name): symbol not found
[2020-06-25T20:29:53Z ERROR wooting_analog_sdk::sdk] Load Plugin failed: Error(Msg("Plugin isn\'t a valid plugin, name function not found"), State { next_error: None, backtrace: InternalBacktrace { backtrace: None } })
[2020-06-25T20:29:53Z WARN  wooting_analog_sdk::sdk] Failed to load any plugins from "/Library/WootingAnalogPlugins/wrapper"!
[2020-06-25T20:29:53Z WARN  wooting_analog_sdk::sdk] Failed to load any plugins from "/Library/WootingAnalogPlugins/plugins"!
[2020-06-25T20:29:54Z INFO  wooting_analog_plugin] Found device impl match: HidDeviceInfo { path: "IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC@14/XHC@14000000/HS13@14a00000/WootingTwo@14a00000/IOUSBHostInterface@6/IOUSBHostHIDDevice@14a00000,6", vendor_id: 1003, product_id: 65282, serial_number: Some("WOOT_001_A01B1927W021H01435"), release_number: 64, manufacturer_string: Some("Wooting"), product_string: Some("WootingTwo"), usage_page: 65364, usage: 1, interface_number: -1 }
[2020-06-25T20:29:54Z INFO  wooting_analog_plugin] Found and opened the Some("WootingTwo") successfully!
[2020-06-25T20:29:54Z DEBUG wooting_analog_plugin] Started timer
[2020-06-25T20:29:54Z INFO  wooting_analog_sdk::sdk] SDKResult(Ok(1))
[2020-06-25T20:29:54Z INFO  wooting_analog_sdk::sdk] 1 plugins successfully initialised

• Running High Sierra, 10.13.6

@simon-wh
Copy link
Member

simon-wh commented Jun 26, 2020

Aha! Turns out, that wasn't a critical error you were getting. As you can see from the log, it attempts to load /Library/WootingAnalogPlugins/wrapper/libwooting_analog_wrapper.dylib as a plugin, which it is not and thus errors. In this case, it doesn't affect the functionality of the SDK as the real plugin was loaded successfully. So you probably want to move the wrapper/ folder out of there to get rid of the errors, but either way, the SDK should still work.

I'll add some additional info to those error messages so it's more clear the source of the problem

@DrMechanica
Copy link
Author

DrMechanica commented Jun 26, 2020

Okay, that makes sense, I think it's working now. Thank you!
I've made up a new place to keep my wrapper folder (/Library/Wooting/wrapper), but I was wondering if there's a recommended standard location for it that you have in mind for the future?

@simon-wh
Copy link
Member

simon-wh commented Jun 29, 2020

I've made up a new place to keep my wrapper folder (/Library/Wooting/wrapper), but I was wondering if there's a recommended standard location for it that you have in mind for the future?

The approach we've been taking so far is that the wrapper should be bundled with your application, not be systemwide. As it's effectively a 'loader' which allows you to safely interact with the SDK and get nice errors even when a user does not have the SDK installed.

So for a 'system-wide' installation it's really up to you, I would only do it if you want to be able to have small Dev applications using the SDK without having to copy the wrapper everywhere. Otherwise, I'd suggest just keeping it alongside your project.

Hope you have fun using the SDK! Any feedback would be greatly appreciated!

Note: keeping this issue open for tracking the improvement of the error logging with plugin loading

@simon-wh simon-wh changed the title MacOS, 'symbol not found', 'Load Plugin failed' (C++) Improve logging when plugin loading fails Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants